This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Web Services and the fly likes Sending a Complex element through the Header. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Sending a Complex element through the Header." Watch "Sending a Complex element through the Header." New topic
Author

Sending a Complex element through the Header.

vazra
Greenhorn

Joined: May 14, 2008
Posts: 2
Hi Guys,
I'm new to web services. I have generated the necessary code from a WSDL file using Axes2 1.4 and Eclipse.
Now my header has a complex element with 6 child elements. The generated code has created a POJO for this complex elements with six instance variables and setters and getters.
I can't seem to figure out how to send this class with the Generated Proxy class.
I have tried using addHeader(SOAPHeaderElement header) and adding all 6 child elements but it keeps throwing a Bad Envelop error.

Any help will be greatly appreciated, I'm ready to pull my hair off after trying to figure this for 6 hrs.
vazra
Greenhorn

Joined: May 14, 2008
Posts: 2
I guess the message doesn't make much sense, here is more info:


I have generated the necessary code from a WSDL file using Axes2 1.4 and Eclipse.
Now the WSDl file has a complexType element with 5 child elements. this is used for the header for all the methods of the webservice.

Complex type in wsdl:

<s:element name="ComplexTypeHeader" type="tns:ComplexTypeHeader" />
<s:complexType name="ComplexTypeHeader">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" default="123" name="id" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" default="123" name="cid" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="wName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="mName" type="s:string" />
</s:sequence>
<s:anyAttribute />
</s:complexType>

An example method:

<wsdl peration name="GetVersion">
<soap12 peration soapAction="http://xyz/GetVersion" style="document" />
<wsdl:input>
<soap12:body use="literal" />
<soap12:header message="tns:GetVersionComplexTypeHeader" part="ComplexTypeHeader" use="literal" />
</wsdl:input>


The generated code has created a POJO for the complex element with five instance variables with setters and getters plus the Locator, SoapStub, proxy.
I can't seem to figure out how to send this class as the input with the Generated Proxy class or the stub class.
I have tried modifying the stub class and adding addHeader(SOAPHeaderElement header) method and adding all 5 child elements but it keeps throwing a Bad Envelop error.

If I just call the method without specifying the Header I keep getting a bad credentials error from the server.

Any help will be greatly appreciated.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

"vazra",
Please check your private messages.
-Ben


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sending a Complex element through the Header.