Solved

Setting client data for a webservice call.

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
javap bin 2 41
eclipse apache tomcat admin console 52 123
spring jars download 1 35
Eclipse Help Java EE 5,6,7 Documentation, why not Java EE 8 8 30
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

820 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