Permalink: www.outsystems.com/goto/web-service-java-extension
Edit: this post refers to an outdated approach at importing web references. The method detailed by Leonardo Fernandes below is prefered.You can still try this method if the preferred one is not desirable for any particular reason.
--------------------------------------
This posts explains how to consume an external WSDL using a Java extension. This technique is usually needed when trying to use unsupported WSDLs.
Steps
Step 1 - Get the necessary files
In order to consume a web service in an extension we'll need some libraries. These are:
These files can be located inside the jboss. They can be found inside the client folder.
Step 2 - Create/Edit the extension
Step 3 - Change the build.xml file of the extension
We need to change the build.xml file to add the libraries to the classpath, so the extension can be correctly compiled. In addition will add a new target to the build.xml file so we can easily generate the stubs that will call the web service.
<fileset dir="${wsConsumeLocation}">
<include name="*.jar" />
</fileset>
<fileset file="${javaHome}\lib\tools.jar" />
<target name="wsdl2java">
<taskdef name="wsconsume" classname="org.jboss.wsf.spi.tools.ant.WSConsumeTask">
<classpath>
<path refid="classpath" />
</classpath>
</taskdef>
<mkdir dir="${build}" />
<wsconsume fork="true" verbose="true" destdir="${build}" sourcedestdir="${src}" keep="true" wsdl="xx" />
</target>
Step 4 - Generate the stubs
Step 5 - Use the generated stubs
xxSoap stub = new xx().getxxSoap();
<target name="refresh-weather-client"> <!-- Change the jdk.home path below to comply with your system --> <property name="jdk.home" value="/usr/java/latest" /> <property name="wsdl" value="https://www.webservicex.com/globalweather.asmx?wsdl" /> <delete dir="outsystems/nosweather/webservice" /> <java classname="com.sun.tools.internal.ws.WsImport"> <classpath> <fileset dir="${jdk.home}/jre/lib"> <include name="*.jar" /> </fileset> <fileset dir="${jdk.home}/lib"> <include name="tools.jar" /> </fileset> </classpath> <arg value="-keep" /> <arg value="-s" /> <arg value="." /> <arg value="-p" /> <arg value="outsystems.nosweather.webservice" /> <arg value="-Xnocompile" /> <arg value="${wsdl}" /> </java> </target>
<target name="refresh-weather-client"> <!-- Change the jdk.home path below to comply with your system --> <property name="jdk.home" value="/usr/java/latest" /> <property name="wsdl" location="outsystems/nosweather/wsdl/globalweather.wsdl" /> <delete dir="outsystems/nosweather/webservice" /> <java classname="com.sun.tools.internal.ws.WsImport"> <classpath> <fileset dir="${jdk.home}/jre/lib"> <include name="*.jar" /> </fileset> <fileset dir="${jdk.home}/lib"> <include name="tools.jar" /> </fileset> </classpath> <arg value="-keep" /> <arg value="-s" /> <arg value="." /> <arg value="-p" /> <arg value="outsystems.nosweather.webservice" /> <arg value="-Xnocompile" /> <arg value="-wsdllocation" /> <arg value="../wsdl/globalweather.wsdl" /> <arg value="${wsdl}" /> </java> </target>
<target name="jar" depends="compile"> <jar destfile="${build}/outsystems.nosweather.jar"> <fileset dir="${build}"> <include name="**/*.class" /> </fileset> <fileset dir="${src}"> <include name="**/*.wsdl" /> <include name="**/*.xsd" /> </fileset> </jar> </target>
<path id="axis.classpath"> <fileset dir="${lib}"> <include name="**/*.jar" /> </fileset> </path> <taskdef resource="axis-tasks.properties" classpathref="axis.classpath" /> <target name="refresh-weather-axis-client"> <property name="remote.wsdl" value="https://www.webservicex.com/globalweather.asmx?wsdl" /> <axis-wsdl2java output="." testcase="false" verbose="true" url="${remote.wsdl}" all="true" timeout="200000"> </axis-wsdl2java> </target>
Long path tool is the very good program for error, unlock solution.
Try it and solve your problem.
I used long path tool and I solve my error, unlock problem solution.