944,150 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Marked Solved
  • Views: 42905
  • Java RSS
Jul 23rd, 2007
0

Auto generate Java Code from WSDL using Axis

Expand Post »
Hi All,

Im Thiyagu, a junior software developer(Java/J2ee). I have assigned to access Webservice (sending request and receiving response from a WSDL). can any tell me the steps involved to convert Java code from a WSDL file using Axis(with ant build script).
please very urgent.

Note : I already tried with Aixs and generated Java code from WSDL , but I got some error while sending request, i.e

Exception in thread "main" AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server
faultSubcode:
faultString: Server was unable to process request. ---> Object reference not set to an instance of an object.
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace: AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server
faultSubcode:
faultString: Server was unable to process request. ---> Object reference not set to an instance of an object.
faultActor:
faultNode:
faultDetail:
Server was unable to process request. ---> Object reference not set to an instance of an object.


Thank,
Thiyagu.
Similar Threads
Reputation Points: 13
Solved Threads: 0
Newbie Poster
thiyagu_mca2006 is offline Offline
10 posts
since Sep 2006
Jul 23rd, 2007
0

Re: Auto generate Java Code from WSDL using Axis

Two things you need to define in your ant properties or build.xml file:
1. Define typeDef for your WSDL to Java utility so as to use in ant target
Java Syntax (Toggle Plain Text)
  1. <typedef name="wsdl2java" classname="org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask" classpathref="axisclasspath"/>
2. Within your desired target say
Java Syntax (Toggle Plain Text)
  1. <wsdl2java verbose="true" output="${yourOutputDir}/wsdl" url="${wsdlFileName}.wsdl" deployScope="Session">
  2. <mapping package="${package}" namespace="urn:${service.name}"/>
  3. </wsdl2java>

Make sure you have mentioned axisclasspath using <path id="axisclasspath">....</path>, which is required by step 1, this is the classpath which ant will internally use to compile WSDL to generate stubs and impl files, so make sure you have mentioned all necessary Axis jars in it.

Hope this will help.
Reputation Points: 10
Solved Threads: 4
Light Poster
ksaxena is offline Offline
31 posts
since Jul 2007
Jul 24th, 2007
0

Re: Auto generate Java Code from WSDL using Axis

no, it is NOT urgent.

The thing to do is to read the documentation, which explains it all in detail.
The steps for using ANT to retrieve the WSDL and generate your classes has already been outlined above though not every option you could use mentioned, use the manual to find out about those.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Jul 25th, 2007
0

Re: Auto generate Java Code from WSDL using Axis

Click to Expand / Collapse  Quote originally posted by ksaxena ...
Two things you need to define in your ant properties or build.xml file:
1. Define typeDef for your WSDL to Java utility so as to use in ant target
Java Syntax (Toggle Plain Text)
  1. <typedef name="wsdl2java" classname="org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask" classpathref="axisclasspath"/>
2. Within your desired target say
Java Syntax (Toggle Plain Text)
  1. <wsdl2java verbose="true" output="${yourOutputDir}/wsdl" url="${wsdlFileName}.wsdl" deployScope="Session">
  2. <mapping package="${package}" namespace="urn:${service.name}"/>
  3. </wsdl2java>

Make sure you have mentioned axisclasspath using <path id="axisclasspath">....</path>, which is required by step 1, this is the classpath which ant will internally use to compile WSDL to generate stubs and impl files, so make sure you have mentioned all necessary Axis jars in it.

Hope this will help.

Dear ksaxena,

Thank you very much for your kind information. The problem I faced was, the Webservice need the Client to send SOAPHeader along with request. I tried it to set SOAPHeaderElement before I invoking service using setHeader(SOAPHeaderElemet). Its working fine now , and I can send and receive response well.

Thanks,
Thiyagu.
Reputation Points: 13
Solved Threads: 0
Newbie Poster
thiyagu_mca2006 is offline Offline
10 posts
since Sep 2006
Jul 25th, 2007
0

Re: Auto generate Java Code from WSDL using Axis

Click to Expand / Collapse  Quote originally posted by jwenting ...
no, it is NOT urgent.

The thing to do is to read the documentation, which explains it all in detail.
The steps for using ANT to retrieve the WSDL and generate your classes has already been outlined above though not every option you could use mentioned, use the manual to find out about those.
Dear jwenting,

Thank you very much for your kind information. The problem I faced was, the Webservice need the Client to send SOAPHeader along with request. I tried it to set SOAPHeaderElement before I invoking service using setHeader(SOAPHeaderElemet). Its working fine now , and I can send and receive response well.

Thanks,
Thiyagu.
Reputation Points: 13
Solved Threads: 0
Newbie Poster
thiyagu_mca2006 is offline Offline
10 posts
since Sep 2006
May 9th, 2010
0
Re: Auto generate Java Code from WSDL using Axis
Hi Thiyagu.,

It seems header part is missing from your request.
To make it sure you can use TCP Monitor to see
what is exact request xml you are creating from your end.

Regards
Mudassar
Reputation Points: 10
Solved Threads: 0
Newbie Poster
MudassarNazar is offline Offline
1 posts
since May 2010

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
This thread is currently closed and is not accepting any new replies.
Previous Thread in Java Forum Timeline: prime number
Next Thread in Java Forum Timeline: Wireless Networks





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC