DaveKub
DaveKub

Reputation: 1005

Axis 1.4 webservice from WSDL

I need to create a webservice (server app, not client) from another company's WSDL file. I've created client apps from WSDL but never a server app. There is no documentation supplied by the other company but I found this online (page 64); it's from 2008 but they tell me the info is still valid (though the links are not). I got Notification.wsdl and Notification.XSD from this zip file.

I used WSDL2Java with this command line:

java org.apache.axis.wsdl.WSDL2Java --server-side Notification.wsdl

and created several java source files and the deploy/undeploy.wsdd files. But the deploy.wsdd doesn't look like I expected it to based on the Axis docs. It only contains:

<deployment
    xmlns="http://xml.apache.org/axis/wsdd/"
    xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
</deployment>

Shouldn't there be a <service> entry at least, or do I need to create that by hand? I expected it to be auto-created. Is something missing in the WSDL file? Or did I miss a step somewhere?

Dave

Upvotes: 0

Views: 9829

Answers (1)

Paulius Matulionis
Paulius Matulionis

Reputation: 23413

If you are using Axis 1.4 command WSDL2Java does not create you a proper .wsdd file. You always need to edit it.

I am using ANT to generated axis server side classes:

   <target name="build-server-jar">
        <mkdir dir="${build}/libs_gen"/>
        <axis-generate serverside="true"
                       srcDir="${ant.dirs.wsdl}"
                       destDir="${build.ws.dir}/${project.name}-server"
                       wsdl="${project.wsdl}"
                       nspkg="${project.nspkg}"/>
        <javac srcdir="${build.ws.dir}/${project.name}-server"
               destdir="${build.ws.dir}/${project.name}-server"
               classpathref="classpath.build"
               includeantruntime="no"/>
        <jar destfile="${build}/libs_gen/my-axis-ws.jar"
             basedir="${build.ws.dir}/${project.name}-server"
             includes="**/*.class"/>
        <copy todir="${lib}" overwrite="true">
            <fileset dir="${build}/libs_gen" includes="my-axis-ws.jar"/>
        </copy>
    </target>

The generated deploy.wsdd file looks like this:

<deployment
    xmlns="http://xml.apache.org/axis/wsdd/"
    xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">

  <service name="MyAxis" provider="java:RPC" style="wrapped" use="literal">
      <parameter name="wsdlTargetNamespace" value="http://example.com/ws/myaxis"/>
      <parameter name="wsdlServiceElement" value="MyAxis"/>
      <parameter name="schemaUnqualified" value="http://example.com/ws/myaxis/types"/>
      <parameter name="wsdlServicePort" value="MyAxis"/>
      <parameter name="className" value="com.example.ws.myaxis.MyAxisPortBindingImpl"/>
      <parameter name="wsdlPortType" value="MyAxisService"/>
      <parameter name="typeMappingVersion" value="1.2"/>

      //Generated operations

      //Generated type mappings.

  </service>
</deployment>

Then I have to edit it to look like this:

<deployment
        xmlns="http://xml.apache.org/axis/wsdd/"
        xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">

    <globalConfiguration>
        <parameter name="disablePrettyXML" value="false"/>
        <parameter name="sendXsiTypes" value="true"/>
        <parameter name="sendMultiRefs" value="true"/>
        <parameter name="sendXMLDeclaration" value="true"/>
    </globalConfiguration>

    <handler name="LocalResponder" type="java:org.apache.axis.transport.local.LocalResponder"/>
    <handler name="URLMapper" type="java:org.apache.axis.handlers.http.URLMapper"/>
    <handler name="Authenticate" type="java:org.apache.axis.handlers.SimpleAuthenticationHandler"/>

    <service name="MyAxis" provider="java:SPRING" style="wrapped" use="literal">
        <parameter name="springBeanId" value="mySpringBean"/>
        <parameter name="wsdlTargetNamespace" value="http://example.com/ws/myaxis"/>
        <parameter name="wsdlServiceElement" value="MyAxis"/>
        <parameter name="schemaUnqualified" value="http://example.com/ws/myaxis/types"/>
        <parameter name="wsdlServicePort" value="MyAxis"/>
        <parameter name="className" value="com.example.ws.myaxis.MyAxisImpl"/>
        <parameter name="wsdlPortType" value="MyAxisService"/>
        <parameter name="typeMappingVersion" value="1.2"/>

        //Generated operations

        //Generated type mappings

        <wsdlFile>WEB-INF/wsdl/MyAxis.wsdl</wsdlFile>
    </service>

    <transport name="http">
        <requestFlow>
            <handler type="URLMapper"/>
            <handler type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/>
        </requestFlow>
    </transport>

</deployment>

Why your WSDL2Java command does not generate service, operations and type mappings my guess is it depends on version you are using.

I am using axis-1.4 and axis-ant-1.4. It generates me everything, but I still need to make some changes. So I suggest you try ANT and use those version and at least service, operations and type mappings will be generated.

Upvotes: 1

Related Questions