Solved

Setting client data for a webservice call.

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
rhino JavaScript import, load 25 84
print map entry 34 69
HashTable highest marks enumeration alternative 9 39
tomcat startup error 5 65
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

809 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