Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Create / Generate Soap Header client stub / java classes using JAX-RPC API

 
naveen babu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Friends,

I tried to generate the Web Service Client Stub in Netbeans 6.1 IDE, but the IDE is generating the Soap Body and not generating the Soap Header stub / java classes.

Can any one help me how to create the Client Soap Header java classes using JAX-RPC API. I want to conver the below wsdl to java classes and use it thru the mobile.

Please some one help me as it is very urgent.

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://localhost/sdk/customerservice" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://localhost/sdk/customerservice" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://localhost/sdk/customerservice">
<s:element name="Authenticate">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="username" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="password" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="AuthenticateResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="AuthenticateResult" type="tns:AuthenticationResult" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="AuthenticationResult">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="CustomerID" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="IsAuthenticated" type="s:boolean" />
</s:sequence>
</s:complexType>
<s:element name="ApiToken" type="tns:ApiToken" />
<s:complexType name="ApiToken">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Token" type="s:string" />
</s:sequence>
<s:anyAttribute />
</s:complexType>
</s:schema>
</wsdl:types>
<wsdl:message name="AuthenticateSoapIn">
<wsdl:part name="parameters" element="tns:Authenticate" />
</wsdl:message>
<wsdl:message name="AuthenticateSoapOut">
<wsdl:part name="parameters" element="tns:AuthenticateResponse" />
</wsdl:message>
<wsdl:message name="AuthenticateApiToken">
<wsdl:part name="ApiToken" element="tns:ApiToken" />
</wsdl:message>
<wsdl:portType name="CustomerServiceSoap">
<wsdlperation name="Authenticate">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Returns the customer id for the authenticated customer. If the authentication failed the returned value will be -1</wsdl:documentation>
<wsdl:input message="tns:AuthenticateSoapIn" />
<wsdlutput message="tns:AuthenticateSoapOut" />
</wsdlperation>
</wsdl:portType>
<wsdl:binding name="CustomerServiceSoap" type="tns:CustomerServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdlperation name="Authenticate">
<soapperation soapAction="http://localhost/sdk/customerservice/Authenticate" style="document" />
<wsdl:input>
<soap:body use="literal" />
<soap:header message="tns:AuthenticateApiToken" part="ApiToken" use="literal" />
</wsdl:input>
<wsdlutput>
<soap:body use="literal" />
</wsdlutput>
</wsdlperation>
</wsdl:binding>
<wsdl:binding name="CustomerServiceSoap12" type="tns:CustomerServiceSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdlperation name="Authenticate">
<soap12peration soapAction="http://localhost/sdk/customerservice/Authenticate" style="document" />
<wsdl:input>
<soap12:body use="literal" />
<soap12:header message="tns:AuthenticateApiToken" part="ApiToken" use="literal" />
</wsdl:input>
<wsdlutput>
<soap12:body use="literal" />
</wsdlutput>
</wsdlperation>
</wsdl:binding>
<wsdl:service name="CustomerService">
<wsdl:port name="CustomerServiceSoap" binding="tns:CustomerServiceSoap">
<soap:address location="https://localhost/soap/customerservice.asmx" />
</wsdl:port>
<wsdl:port name="CustomerServiceSoap12" binding="tns:CustomerServiceSoap12">
<soap12:address location="https://localhost/soap/customerservice.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello "naveen naveen"-

On your way in you may have missed that we have a policy on screen names here at JavaRanch. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.

As to your question, what do you mean by "SOAP body" and "SOAP header"? The tools don't generate any SOAP, they generate code to make and/or receive SOAP requests. If that's not what's happening in your case, tell us what is happening.
 
Karthic Raghupathi
Greenhorn
Posts: 9
Java jQuery Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess what he meant was the Netbeans IDE does not generate the stub which includes handling the Authentication. Let me explain a bit. I'm having the same issue currently.

I'm trying to consume a web service created in .NET which needs SOAP authentication. Here is a link to the webservice.

The part that you would be most interested is this:


When consuming the web service using the instuctions given here under the sections "Creating Proxy in Java" and "Write code in Java to call web service" fails because we are not able to add the authentication part in the code.

When automatically generating the code in Netbeans it gives us this:

Using JAX-WS


Using JAX-RPC


At the least when I use JAX-WS method, I get a class called SoapAuthenticationHeader in which I can set the username and password. But I'm not able to bind it with the service or port objects.


I do not have this option in JAX-RPC method.

Any inputs on this would be greatly appreciated. Thanks in advance for your time.
 
Karthic Raghupathi
Greenhorn
Posts: 9
Java jQuery Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bump

pardon me.. i was just hoping this post would catch your attention... if it is against forum rules, please forgive my ignorance...
 
Annu Vinayak
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see that there are no replies to the message by Karthic Raghupathi.

I am facing a smiliar scenario and need to add an authentication header to a JAX RPC client. (The autogenerated stub classes do not contain any classes for adding the header to my SOAP message)

Reuqest you to provide some information on this issue.

Thanks,
Annu
 
Karthic Raghupathi
Greenhorn
Posts: 9
Java jQuery Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I keep running into such issues every now and then.

I come back to see if there is an answer but no luck yet. Hopefully someone will have an answer soon enough.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic