Solved

Setting client data for a webservice call.

Posted on 2010-09-12
1
303 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
allswap challenge 6 79
Non-recursive backtracking, using a stack 1 103
recursion example 16 111
map related example 6 36
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…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

895 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now