Child pages
  • Axis 1.4 WSDL2Java hiba
Skip to end of metadata
Go to start of metadata
Sziasztok!

Egy drupal webservice-t szeretnék használni java klienssel. Már sikerült meghívni a user.login műveletet az alábbi kóddal, vissza is adja az eredményt, viszont a type mapping-ek nem igazán működnek jól, ezért gondoltam kigenerálom a szükséges osztályokat a wsdlből WSDL2Java-val. Ez nem sikerül, mert nem találja az Array xml típust, holott a WSDL-ben benne van a namespace import is. Keresgéltem a neten, de mindenhol azt írják, az a baj, hogy nincs definiálva a típus, viszont a wsdl-ben benne van:
 <xsd:complexType name="Array">
  <xsd:complexContent>
   <xsd:restriction base="SOAP-ENC:Array">
    <xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:pair[]"/>
   </xsd:restriction>
  </xsd:complexContent>
 </xsd:complexType>

Előre is köszi a segítséget!
pentike


A jelenlegi kód, ami a hívást jól elvégzi, csak nem tudom kiszedni a visszatérési értéket:
            Service service = new Service();
            Call call = (Call) service.createCall();
            call.setTargetEndpointAddress(endpoint);
            call.setEncodingStyle(namespaceURI);
            call.registerTypeMapping(org.w3c.dom.Element.class, new QName(
                    "unnamed_struct_use_soapval"),
                    new ElementSerializerFactory(),
                    new ElementDeserializerFactory());
            call
                    .setOperationName(new QName(
                            "http://localhost/zeneszapro/services/soap/",
                            "user.login"));
            QName xmlType = new QName("string");
            Element[] ret = (Element[]) call.invoke(new Object[] { "sessionid",
                    "Admin", "12zeneszapro34" });
            for (Element e : ret) {
                System.out.println("WS returned: " + e.getTextContent() + " "
                        + e.getNodeName() + " " + e.getNodeType());
            }
pentike@saman:~/java/axis-1_4/lib$ java -cp .:axis.jar:wsdl4j-1.5.1.jar:commons-discovery-0.2.jar:commons-logging-1.0.4.jar:jaxrpc.jar:log4j.properties:log4j-1.2.8.jar org.apache.axis.wsdl.WSDL2Java -o za za.wsdl
- Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled.
java.io.IOException: Type {http://www.w3.org/2001/XMLSchema}Array is referenced but not defined.
        at org.apache.axis.wsdl.symbolTable.SymbolTable.checkForUndefined(SymbolTable.java:665)
        at org.apache.axis.wsdl.symbolTable.SymbolTable.add(SymbolTable.java:545)
        at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:518)
        at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:495)
        at org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:361)
        at java.lang.Thread.run(Thread.java:619)

A WSDL:
<?xml version="1.0" encoding="ISO-8859-1"?>
<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://localhost/zeneszapro/services/soap/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://localhost/zeneszapro/services/soap/">
<types>
<xsd:schema targetNamespace="http://localhost/zeneszapro/services/soap/"
> <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" /> <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" /> <xsd:complexType name="pair"> <xsd:all> <xsd:element name="title" type="xsd:string"/> <xsd:element name="value" type="xsd:string"/> </xsd:all> </xsd:complexType> <xsd:complexType name="Array"> <xsd:complexContent> <xsd:restriction base="SOAP-ENC:Array"> <xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:pair[]"/> </xsd:restriction> </xsd:complexContent> </xsd:complexType> </xsd:schema> </types> <message name="search.searchNodesRequest"> <part name="sessid" type="xsd:string" /> <part name="search_keys" type="xsd:string" /> <part name="simple" type="xsd:string" /></message> <message name="search.searchNodesResponse"> <part name="return" type="xsd:Array" /></message> <message name="search.searchUsersRequest"> <part name="sessid" type="xsd:string" /> <part name="search_keys" type="xsd:string" /></message> <message name="search.searchUsersResponse"> <part name="return" type="xsd:Array" /></message> <message name="user.loginRequest"> <part name="sessid" type="xsd:string" /> <part name="username" type="xsd:string" /> <part name="password" type="xsd:string" /></message> <message name="user.loginResponse"> <part name="return" type="xsd:Array" /></message> <message name="user.logoutRequest"> <part name="sessid" type="xsd:string" /></message> <message name="user.logoutResponse"> <part name="return" type="xsd:Array" /></message> <portType name="DrupalSoapPortType"> <operation name="search.searchNodes"> <documentation>Searches nodes according to keys via hook_search.</documentation> <input message="tns:search.searchNodesRequest"/> <output message="tns:search.searchNodesResponse"/> </operation> <operation name="search.searchUsers"> <documentation>Searches users according to keys via hook_search.</documentation> <input message="tns:search.searchUsersRequest"/> <output message="tns:search.searchUsersResponse"/> </operation> <operation name="user.login"> <documentation>Logs in a user.</documentation> <input message="tns:user.loginRequest"/> <output message="tns:user.loginResponse"/> </operation> <operation name="user.logout"> <documentation>Logs out a user.</documentation> <input message="tns:user.logoutRequest"/> <output message="tns:user.logoutResponse"/> </operation> </portType> <binding name="DrupalSoapBinding" type="tns:DrupalSoapPortType"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="search.searchNodes"> <soap:operation soapAction="http://localhost/zeneszapro/services/soap/search.searchNodes" style="rpc"/> <input><soap:body use="encoded" namespace="http://localhost/zeneszapro/services/soap/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input> <output><soap:body use="encoded" namespace="http://localhost/zeneszapro/services/soap/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output> </operation> <operation name="search.searchUsers"> <soap:operation soapAction="http://localhost/zeneszapro/services/soap/search.searchUsers" style="rpc"/> <input><soap:body use="encoded" namespace="http://localhost/zeneszapro/services/soap/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input> <output><soap:body use="encoded" namespace="http://localhost/zeneszapro/services/soap/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output> </operation> <operation name="user.login"> <soap:operation soapAction="http://localhost/zeneszapro/services/soap/user.login" style="rpc"/> <input><soap:body use="encoded" namespace="http://localhost/zeneszapro/services/soap/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input> <output><soap:body use="encoded" namespace="http://localhost/zeneszapro/services/soap/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output> </operation> <operation name="user.logout"> <soap:operation soapAction="http://localhost/zeneszapro/services/soap/user.logout" style="rpc"/> <input><soap:body use="encoded" namespace="http://localhost/zeneszapro/services/soap/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input> <output><soap:body use="encoded" namespace="http://localhost/zeneszapro/services/soap/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output> </operation> </binding> <service name="DrupalSoap"> <port name="DrupalSoapPort" binding="tns:DrupalSoapBinding"> <soap:address location="http://localhost/zeneszapro/services/soap/"/> </port> </service> </definitions>



      
      
Page viewed times
#trackbackRdf ($trackbackUtils.getContentIdentifier($page) $page.title $trackbackUtils.getPingUrl($page))
  • No labels

2 Comments

  1. Hmmm... most látom, hogy nem stimmel a namespace. Ebben van az Array:
    <xsd:schema targetNamespace="http://localhost/zeneszapro/services/soap/">

    az üzenetekben viszont
    <message name="search.searchNodesResponse">
    <part name="return" type="xsd:Array"/>
    </message>
    Az xsd névtér viszont a http://www.w3.org/2001/XMLSchema
    
    <definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"  xmlns:xsd="http://www.w3.org/2001/XMLSchema"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"  xmlns:tns="http://localhost/zeneszapro/services/soap/"  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"  xmlns="http://schemas.xmlsoap.org/wsdl/"  targetNamespace="http://localhost/zeneszapro/services/soap/">
    

  2. Lecseréltem az xsd:Array-t -> tns:Array -re és jól lefutott.

    Csak a rend kedvéért:
    php NuSOAP a szerver, az generált rossz WSDL-t
    a kliens Apache Axis 1.4