Hallo,
nutze Axis2-1.3 sowie Eclipse und Java5. Mein Problem ist nun das ich nicht auf meinen Webservices zugreifen kann. Dieser basiert auf wsdl2.0. Deshalb greifen die ganzen Generierungswerkzeuge nicht. Meine Frage ist nun wie eine SOAP Anfrage-Nachricht aussehen müsste. Der Quellcode meines bisherigen Clients
generiert die Soap Nachricht
sowie einen Fehler
Hier noch die WSDL 2.0 Datei:
Danke im Voraus schonmal für die Hilfe!
Viele Grüße
Björn
nutze Axis2-1.3 sowie Eclipse und Java5. Mein Problem ist nun das ich nicht auf meinen Webservices zugreifen kann. Dieser basiert auf wsdl2.0. Deshalb greifen die ganzen Generierungswerkzeuge nicht. Meine Frage ist nun wie eine SOAP Anfrage-Nachricht aussehen müsste. Der Quellcode meines bisherigen Clients
Code:
public WebserviceClientGetSquare(float request) { /** * Webservice endpoint */ String endpoint = "http://localhost:8888/axis2/services/SquareService"; /** * Response Variable */ response = (float) 0.0; try { SOAPConnectionFactory soapConnFactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = soapConnFactory.createConnection(); MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage message = messageFactory.createMessage(); SOAPPart soapPart = message.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); envelope.addNamespaceDeclaration("tns", "http://ns.MyService:8888/SquareService"); String str = Float.toString(request); SOAPBody body = envelope.getBody(); SOAPElement bodyElement = body.addChildElement(envelope.createName(operation, "tns", "urn:"+urn)); bodyElement.addChildElement("SquareRequest").addChildElement("x").addTextNode(str); message.saveChanges(); System.out.println("\nRequest:\n"); message.writeTo(System.out); System.out.println(); SOAPMessage reply = connection.call(message, endpoint); soapPart = reply.getSOAPPart(); envelope = soapPart.getEnvelope(); body = envelope.getBody(); Iterator iter = body.getChildElements(); Node resultOuter = ((Node) iter.next()).getFirstChild(); Node result = resultOuter.getFirstChild(); System.out.println("add("+str+") = "+result.getNodeValue()); this.response = Float.valueOf(result.getNodeValue()).floatValue(); // Close the connection connection.close(); } catch (Exception e) { System.out.println(e.getMessage()); } }
Code:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://ns.MyService:8888/SquareService"> <soapenv:Body> <tns:getSquare xmlns:tns="urn:getSquare"> <SquareRequest> <x>5.0</x> </SquareRequest> </tns:getSquare> </soapenv:Body> </soapenv:Envelope>
Code:
org.apache.axis2.databinding.ADBException: Unexpected subelement getSquare
Code:
<description xmlns="http://www.w3.org/ns/wsdl" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:tns="http://ns.MyService:8888/SquareService" xmlns:wsoap="http://www.w3.org/ns/wsdl/soap" xmlns:wsdlx="http://www.w3.org/ns/wsdl-extensions" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:whttp="http://www.w3.org/ns/wsdl/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://ns.MyService:8888/SquareService"><documentation>This service provides an operation getSquare, that calculates the square of an input. The input must be a float and greater than or equal zero.</documentation><types><xsd:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://ns.MyService:8888/SquareService"> <xsd:element name="SquareRequest" type="tns:RequestType" /> <xsd:element name="SquareResponse" type="tns:ResponseType" /> <xsd:element name="SquareFault" type="tns:FaultType" /> <xsd:complexType name="RequestType"> <xsd:sequence> <xsd:element name="x" type="xsd:float" /> </xsd:sequence> </xsd:complexType> <xsd:complexType name="ResponseType"> <xsd:sequence> <xsd:element name="y" type="xsd:float" /> </xsd:sequence> </xsd:complexType> <xsd:complexType name="FaultType"> <xsd:all> <xsd:element name="errorMessage" type="xsd:string" /> </xsd:all> </xsd:complexType> </xsd:schema></types><interface name="getSquareInterface"><fault name="SquareFault" element="tns:SquareFault" /><operation name="getSquare" pattern="http://www.w3.org/ns/wsdl/in-out" wsdlx:safe="false"><input element="tns:SquareRequest" wsaw:Action="urn:getSquare" /><output element="tns:SquareResponse" wsaw:Action="urn:getSquareResponse" /><outfault ref="tns:SquareFault" wsaw:Action="urn:getSquareSquareFault" /></operation></interface><binding name="GetSquareSOAPBinding" interface="tns:getSquareInterface" type="http://www.w3.org/ns/wsdl/soap" wsoap:version="1.2" wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP/" wsoap:mepDefault="http://www.w3.org/2003/05/soap/mep/request-response" whttp:queryParameterSeparatorDefault="&"><fault ref="tns:SquareFault" wsoap:code="Sender" /><operation ref="tns:getSquare" /></binding><service name="SquareService" interface="tns:getSquareInterface"><endpoint name="GetSquareEP" binding="tns:GetSquareSOAPBinding" address="http://localhost:8888/axis2/services/SquareService" /></service></description>
Viele Grüße
Björn
Comment