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.

Recommended Answers

All 5 Replies

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

<typedef name="wsdl2java" classname="org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask" classpathref="axisclasspath"/>

2. Within your desired target say

<wsdl2java verbose="true" output="${yourOutputDir}/wsdl" url="${wsdlFileName}.wsdl" deployScope="Session">
	<mapping package="${package}" namespace="urn:${service.name}"/>
</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.

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.

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

<typedef name="wsdl2java" classname="org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask" classpathref="axisclasspath"/>

2. Within your desired target say

<wsdl2java verbose="true" output="${yourOutputDir}/wsdl" url="${wsdlFileName}.wsdl" deployScope="Session">
    <mapping package="${package}" namespace="urn:${service.name}"/>
</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.

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.