Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Setting client data for a webservice call.

Posted on 2010-09-12
1
Medium Priority
?
312 Views
Last Modified: 2012-05-10
I'm attempting to access a webservice.

I've created the client code using wsdls2Java tool within myeclipse.

It created the below information.

This class was generated by the JAX-WS RI. JAX-WS RI 2.1.3-hudson-390-
 * Generated source version: 2.0
 * <p>
 * An example of how this class may be used:
 *
 * <pre>
 * SDDWFWS service = new SDDWFWS();
 * WFSDDPort portType = service.getSDDWFWS();
 * portType.wfsddOperation(...);
 * </pre>


In my testclient code I know the portType.wfsddOperation takes a payload object.
I'm attempting to set the payload data.
I can successfully set the PayLoadID which is a string but I can't seem to set the PayloadData attributes with my String p.   Any ideas?

Thanks in advance.




public class TestClient {

      /**
       * @param args
       */
      public static void main(String[] args) {
            
            
            String p = "<ns1:InvNotice xmlns:ns1=\"http://abc.wfhm.default.InvestorNotice.xsd\">" +
                        "<ns1:AppPackageID>12345</ns1:AppPackageID>" +
                        "<ns1:PackageID>67890</ns1:PackageID>"+
                        "<ns1:Process>InvestorNotice</ns1:Process>"+
                        "<ns1:Activity>EmailNotification</ns1:Activity>"+
                        "<ns1:Action>Complete</ns1:Action>"+
                        "<ns1:AsOfDateTime>2010-08-25T18:12:03.865-05:00</ns1:AsOfDateTime>"+
                        "<ns1:SourceSystem>SDD</ns1:SourceSystem> " +
                        " </ns1:InvNotice>";
            
            
            Payload payload = new Payload();
            
            payload.setPayLoadID("SteveTest-08302010");
            
            
            
            PayloadData payloaddata = payload.getPayloadData();
            
             payload.setPayloadData();    //?????
            
            
            
            
            SDDWFWS service = new SDDWFWS();
            WFSDDPort portType = service.getSDDWFWS();
            //portType.
            // Input
             portType.wfsddOperation(payload);
      

      }



/**
 * <p>
 * Java class for anonymous complex type.
 *
 * <p>
 * The following schema fragment specifies the expected content contained within
 * this class.
 *
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element ref="{http://LPS.Desktop.abc.WebService.Data.Payload/1.0}PayLoadID"/>
 *         &lt;element ref="{http://LPS.Desktop.abc.WebService.Data.Payload/1.0}PayloadData"/>
 *         &lt;element ref="{http://LPS.Desktop.abc.WebService.Data.Payload/1.0}PayloadHeader"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "payLoadID", "payloadData", "payloadHeader" })
@XmlRootElement(name = "Payload")
public class Payload {

      @XmlElement(name = "PayLoadID", required = true)
      protected String payLoadID;
      @XmlElement(name = "PayloadData", required = true)
      protected PayloadData payloadData;
      @XmlElement(name = "PayloadHeader", required = true)
      protected PayloadHeader payloadHeader;

      /**
       * Gets the value of the payLoadID property.
       *
       * @return possible object is {@link String }
       *
       */
      public String getPayLoadID() {
            return payLoadID;
      }

      /**
       * Sets the value of the payLoadID property.
       *
       * @param value
       *            allowed object is {@link String }
       *
       */
      public void setPayLoadID(String value) {
            this.payLoadID = value;
      }

      /**
       * Gets the value of the payloadData property.
       *
       * @return possible object is {@link PayloadData }
       *
       */
      public PayloadData getPayloadData() {
            return payloadData;
      }

      /**
       * Sets the value of the payloadData property.
       *
       * @param value
       *            allowed object is {@link PayloadData }
       *
       */
      public void setPayloadData(PayloadData value) {
            this.payloadData = value;
      }

      /**
       * Gets the value of the payloadHeader property.
       *
       * @return possible object is {@link PayloadHeader }
       *
       */
      public PayloadHeader getPayloadHeader() {
            return payloadHeader;
      }

      /**
       * Sets the value of the payloadHeader property.
       *
       * @param value
       *            allowed object is {@link PayloadHeader }
       *
       */
      public void setPayloadHeader(PayloadHeader value) {
            this.payloadHeader = value;
      }

}





/**
 * <p>
 * Java class for PayloadData complex type.
 *
 * <p>
 * The following schema fragment specifies the expected content contained within
 * this class.
 *
 * <pre>
 * &lt;complexType name="PayloadData">
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;any/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "PayloadData", propOrder = { "any" })
public class PayloadData {

      @XmlAnyElement(lax = true)
      protected List<Object> any;

      /**
       * Gets the value of the any property.
       *
       * <p>
       * This accessor method returns a reference to the live list, not a
       * snapshot. Therefore any modification you make to the returned list will
       * be present inside the JAXB object. This is why there is not a
       * <CODE>set</CODE> method for the any property.
       *
       * <p>
       * For example, to add a new item, do as follows:
       *
       * <pre>
       * getAny().add(newItem);
       * </pre>
       *
       *
       * <p>
       * Objects of the following type(s) are allowed in the list {@link Object }
       * {@link Element }
       *
       *
       */
      public List<Object> getAny() {
            if (any == null) {
                  any = new ArrayList<Object>();
            }
            return this.any;
      }

}

0
Comment
Question by:sdittmann
1 Comment
 

Accepted Solution

by:
sdittmann earned 0 total points
ID: 33664068
I've found a solution.
 
               PayloadData pd = new PayloadData();
               Payload pl = new Payload();
               PayloadHeader ph = new PayloadHeader();
               
               pl.setPayLoadID("12345");
               ph.setMessageType("LoanEvent");
               ph.setSourceSystem("SDD");
               pl.setPayloadHeader(ph);
               
      
               JAXBElement<Object> xmlelement = new JAXBElement<Object>(new QName("PackageHeader"),Object.class, innot);

               pd.getAny().add(xmlelement);
               pl.setPayloadData(pd);
               
               
               SDDWFWS service =  new SDDWFWS();
               WFSDDPort prt = service.getSDDWFWS();
               Acknowledge ak = prt.wfsddOperation(pl);
               
                  System.out.println("Tester End " + ak.getAcknowledgeID());
               
         }catch ( Exception e)
         {
                  System.out.println("Tester Exception " + e.getMessage());
         }
            
      }
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question