Solved

Setting client data for a webservice call.

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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 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 tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

708 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

19 Experts available now in Live!

Get 1:1 Help Now