axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antonio Ruiz Martínez <...@dif.um.es>
Subject Big problem generating correct code with WSDL2Java
Date Tue, 11 Jan 2005 18:53:48 GMT
Hello!

    I'm writing you because I'm having a lot of problems to generate a 
simple web service from a file .wsdl that is very simple. I wonder if 
you could help me please. I'm going to try to describe the steps that 
I'm doing. For this example, I'm using axis1.2rc2.

1) The command that I'm using to generate the code is the following:

java org.apache.axis.wsdl.WSDL2Java --server-side --skeletonDeploy true 
-p signservice pruebacarm.wsdl

file.wsdl
---------
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 
xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" 
xmlns:dss="urn:testsign" targetNamespace="urn:testsign" name="urn:testsign">
    <types>
        <xs:schema targetNamespace="urn:testsign" 
xmlns:xs="http://www.w3.org/2001/XMLSchema">
            <xs:element name="SignRequest">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="ID" type="xs:string"/>
                        <xs:element name="status" type="xs:int"/>
                    </xs:sequence>
                    <xs:attribute name="RequestID" type="xs:string" 
use="optional"/>
                    <xs:attribute name="Profile" type="xs:string" 
use="optional"/>
                </xs:complexType>
            </xs:element>
            <xs:element name="SignResponse">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="IDres" type="xs:string"/>
                        <xs:element name="statusRes" type="xs:int"/>
                    </xs:sequence>
                    <xs:attribute name="RequestID" type="xs:string" 
use="optional"/>
                    <xs:attribute name="Profile" type="xs:string" 
use="required"/>
                </xs:complexType>
            </xs:element>
        </xs:schema>
    </types>
    <message name="SignRequestIn">
        <part name="body" element="dss:SignRequest"/>
    </message>
    <message name="SignRequestOut">
        <part name="body" element="dss:SignResponse"/>
    </message>
    <portType name="SignRequestSOAP">
        <operation name="getSign">
            <input message="dss:SignRequestIn"/>
            <output message="dss:SignRequestOut"/>
        </operation>
    </portType>
    <binding name="SignRequestSOAPBinding" type="dss:SignRequestSOAP">
        <soap:binding style="document" 
transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="getSign">
            <soap:operation soapAction="urn:eSignService#getSign"/>
            <input>
                <soap:body use="literal"/>
            </input>
            <output>
                <soap:body use="literal"/>
            </output>
        </operation>
    </binding>
    <service name="eSignService">
        <port name="eSignServicePort" binding="dss:SignRequestSOAPBinding">
            <soap:address 
location="http://micropeich.dif.um.es:8080/axis/services/eSignServicePort"/>
        </port>
    </service>
</definitions>


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

  <!-- Services from eSignService WSDL service -->

  <service name="eSignServicePort" provider="java:RPC" style="document" 
use="literal">
      <parameter name="wsdlTargetNamespace" value="urn:testsign"/>
      <parameter name="wsdlServiceElement" value="eSignService"/>
      <parameter name="wsdlServicePort" value="eSignServicePort"/>
      <parameter name="className" 
value="signservice.SignRequestSOAPBindingSkeleton"/>
      <parameter name="wsdlPortType" value="SignRequestSOAP"/>
      <parameter name="allowedMethods" value="*"/>

      <typeMapping
        xmlns:ns="urn:testsign"
        qname="ns:>SignResponse"
        type="java:signservice.SignResponse"
        serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
        deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
        encodingStyle=""
      />
      <typeMapping
        xmlns:ns="urn:testsign"
        qname="ns:>SignRequest"
        type="java:signservice.SignRequest"
        serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
        deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
        encodingStyle=""
      />
  </service>
</deployment>

2) I write the code of the SignRequestSOAPImpl.java
3) then compile the code and deploy the service.

Some comments to the code generated by the tool:
- The name that uses to generate the name of the service is the name of 
the port in the .wsdl file (in my example, eSignServicePort)  when I 
think that the name should be the name of the service name (in my 
example, eSignService) or the name of the service location. However, the 
code that generate in the class ESignServiceLocator.java in the variable:

private java.lang.String eSignServicePort_address = 
"http://micropeich.dif.um.es:8080/axis/services/eSignServicePort";

It is using the URL of the location I don't know if this is a bug or 
there are indepent things. But this is not my problem because I solved 
it putting in the location of the service that the name of the service 
is the name of the port.

4) I test it with the following request:
<SOAP-ENV:Envelope 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <SOAP-ENV:Body>
        <m:SignRequest xmlns:m="urn:testsign" RequestID="" Profile="">
            <ID>String</ID>
            <status>0</status>
        </m:SignRequest>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

5) then I'm getting the following message error:

<soapenv:Envelope 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
        <soapenv:Fault>
            <faultcode 
xmlns:ns1="http://xml.apache.org/axis/">ns1:Client</faultcode>
            <faultstring>No such operation 'SignRequest'</faultstring>
            <detail>
                <ns2:hostname 
xmlns:ns2="http://xml.apache.org/axis/">micropeich</ns2:hostname>
            </detail>
        </soapenv:Fault>
    </soapenv:Body>
</soapenv:Envelope>

6) Then undeploy the service and I fix the deploy file
<deployment
    xmlns="http://xml.apache.org/axis/wsdd/"
    xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">

  <!-- Services from eSignService WSDL service -->

  <service name="eSignServicePort" provider="java:RPC" style="document" 
use="literal">
      <parameter name="wsdlTargetNamespace" value="urn:testsign"/>
      <parameter name="wsdlServiceElement" value="eSignService"/>
      <parameter name="wsdlServicePort" value="eSignServicePort"/>
      <parameter name="className" 
value="signservice.SignRequestSOAPBindingSkeleton"/>
      <parameter name="wsdlPortType" value="SignRequestSOAP"/>
      <parameter name="allowedMethods" value="*"/>

      <typeMapping
        xmlns:ns="urn:testsign"
        qname="ns:>SignResponse"
        type="java:signservice.SignResponse"
        serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
        deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
        encodingStyle=""
      />
      <typeMapping
        xmlns:ns="urn:testsign"
        qname="ns:>SignRequest"
        type="java:signservice.SignRequest"
        serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
        deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
        encodingStyle=""
      />
  </service>
</deployment>

7) I'm getting the following error:

<soapenv:Envelope 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
        <soapenv:Fault>
            <faultcode>soapenv:Server.userException</faultcode>
            <faultstring>java.lang.ClassCastException: 
org.apache.axis.encoding.ser.BeanDeserializer</faultstring>
            <detail>
                <ns1:hostname 
xmlns:ns1="http://xml.apache.org/axis/">micropeich</ns1:hostname>
            </detail>
        </soapenv:Fault>
    </soapenv:Body>
</soapenv:Envelope>

Could you help me, please? I have not any idea at all what the problem is?
I have been looking at the example AddressBook and it uses a class 
called DOMUtils. Which is the goal of this class? Should I use it? in 
afirmative answer: How?

Regards,
Antonio.


Mime
View raw message