I Fixed the error : no such method, and did follow the below steps in
creating a payload and invoking the operation,
However, I get following error:
09/05/2011 10:37:17 AM axiomtryout.NewServiceClient creatClient
SEVERE: null
org.apache.axis2.AxisFault: The getValue operation cannot be found.
at
org.apache.axis2.client.ServiceClient.createClient(ServiceClient.java:647)
at
org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:537)
at
axiomtryout.NewServiceClient.creatClient(NewServiceClient.java:40)
at axiomtryout.Main.main(Main.java:35)
I used TCP Monitor and I get Following POST
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header
xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:To>http://localhost:6060/axis2/services/TwoPara</wsa:To>
<wsa:MessageID>urn:uuid:4BF80F83066F1D03B11304902610754</wsa:MessageID>
<wsa:Action>getValue</wsa:Action>
</soapenv:Header>
<soapenv:Body>
<getValue:getValue xmlns:getValue="http://services/xsd">
<getValue:n1>1000</getValue:n1>
<getValue:n2>1000</getValue:n2>
</getValue:getValue>
</soapenv:Body>
</soapenv:Envelope>0
The RESPONSE is
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header
xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:Action>http://www.w3.org/2005/08/addressing/soap/fault</wsa:Action>
<wsa:RelatesTo>urn:uuid:4BF80F83066F1D03B11304902610754</wsa:RelatesTo>
</soapenv:Header>
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server</faultcode>
<faultstring>unknown</faultstring>
<detail />
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
Any Idea?
>>> Martin Gainty <[email protected]> 6/05/2011 9:23 PM >>>
<!-- wsdl bindings appear incorrect assume this namespace declaration
in wsdl:definitions -->
<wsdl:definitions xmlns:ns="http://complex.tempuri.org"...>
<!-- then wsdl would define service posts for SOAP11point, SOAP12point
and HttpEndpoint -->
<wsdl:service name="ComplexDataTypes">
<wsdl:port name="ComplexDataTypesHttpSoap11Endpoint"
binding="ns:ComplexDataTypesSoap11Binding">
<soap:address
location="http://localhost:8080/axis2/services/ComplexDataTypes"/>
</wsdl:port>
<wsdl:port name="ComplexDataTypesHttpSoap12Endpoint"
binding="ns:ComplexDataTypesSoap12Binding">
<soap12:address
location="http://localhost:8080/axis2/services/ComplexDataTypes"/>
</wsdl:port>
<wsdl:port name="ComplexDataTypesHttpEndpoint"
binding="ns:ComplexDataTypesHttpBinding">
<http:address
location="http://localhost:8080/axis2/services/ComplexDataTypes"/>
</wsdl:port>
</wsdl:service>
<!-- the aforementioned ComplexDataTypesSoap11Binding binding is
declared as -->
<wsdl:binding name="ComplexDataTypesSoap11Binding"
type="ns:ComplexDataTypesPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document"/>
<wsdl:operation name="retUri">
<soap:operation soapAction="urn:retUri" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<!-- where the aforementioned retUri Element is declared as complexType
here -->
<xs:schema xmlns:ax25="http://data.complex.tempuri.org/xsd"
xmlns:ax26="http://arrays.data.complex.tempuri.org/xsd"
attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="http://complex.tempuri.org">
<xs:import
namespace="http://data.complex.tempuri.org/xsd"/>
<xs:import
namespace="http://arrays.data.complex.tempuri.org/xsd"/>
<xs:element name="retUri">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="inUri"
nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
//payload is a OMElement which will be received by method getValue
identitied as retUri *an array of strings* as seen here
OMNamespace omNs = factory.createOMNamespace(
"http://complex.tempuri.org", "retUri");
//method name
OMElement method = factory.createOMElement("retUri", omNs);
//value if any
OMElement value = factory.createOMElement("Text", omNs);
value.addChild(factory.createOMText(value, "Test String "));
//add the value to the testUri method
method.addChild(value);
//the QName consists of the namespace and the aforementioned retUri
operation
//the second param is the OMElement payload previously constructed
which contains the value
OMElement response = serviceClient.sendReceive(new QName("retUri"),
method);
this all works wonderfully a well-formed and validated wsdl and using
the wsdl2java utility
wsdl2java -uri *.wsdl
Martin Gainty
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de
confidentialité
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede
unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig.
Diese Nachricht dient lediglich dem Austausch von Informationen und
entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten
Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt
uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas
le destinataire prévu, nous te demandons avec bonté que pour satisfaire
informez l'expéditeur. N'importe quelle diffusion non autorisée ou la
copie de ceci est interdite. Ce message sert à l'information seulement
et n'aura pas n'importe quel effet légalement obligatoire. Étant donné
que les email peuvent facilement être sujets à la manipulation, nous ne
pouvons accepter aucune responsabilité pour le contenu fourni.
Date: Fri, 6 May 2011 13:05:44 +1000
From: [email protected]
To: [email protected]
Subject: NoSuchMethodError:
org.apache.axis2.addressing.EndpointReference.isWSAddressingAnonymous()Z
Hi all,
I am trying a short sample code for Dynamic client as I was getting
many errors with my previous post configuration context and addressing.
I modified my code to ;
public void creatClient() {
try {
ConfigurationContext configContext =
ConfigurationContextFactory.createConfigurationContextFromFileSystem("C:/axis2-1.5.4/repository",
"C:/axis2-1.5.4/conf/axis2.xml");
Options opts = new Options();
ServiceClient dynamicClient = new
ServiceClient(configContext, new
URL("http://localhost:8080/axis2/services/TwoPara?wsdl"), null, null);
OMElement responce = dynamicClient.sendReceive(new
QName("http://services","getValue"),getPayload (
http://services%22,%22getValue%22%29,getPayload )());;
} catch (MalformedURLException ex) {
Logger.getLogger(NewServiceClient.class.getName()).log(Level.SEVERE,
null, ex);
} catch (AxisFault ex) {
Logger.getLogger(NewServiceClient.class.getName()).log(Level.SEVERE,
null, ex);
}
}
public static OMElement getPayload() {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace("http://services/xsd",
"xs");
OMElement method = fac.createOMElement("getValue", omNs);
OMElement value1 = fac.createOMElement("n1", omNs);
value1.setText("1000");
method.addChild(value1);
OMElement value2 = fac.createOMElement("n2", omNs);
value2.setText("1000");
method.addChild(value2);
return method;
}
However Now I am getting an Addressing Exception as below;
INFO: Deploying Web service: version.aar
Exception in thread "main" java.lang.NoSuchMethodError:
org.apache.axis2.addressing.EndpointReference.isWSAddressingAnonymous()Z
at
org.apache.axis2.handlers.addressing.AddressingOutHandler$WSAHeaderWriter.processToEPR(AddressingOutHandler.java:422)
at
org.apache.axis2.handlers.addressing.AddressingOutHandler$WSAHeaderWriter.writeHeaders(AddressingOutHandler.java:214)
at
org.apache.axis2.handlers.addressing.AddressingOutHandler.invoke(AddressingOutHandler.java:135)
at org.apache.axis2.engine.Phase.invoke(Phase.java:292)
at
org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:212)
at
org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:377)
at
org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:374)
at
org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:211)
at
org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at
org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:528)
at
axiomtryout.NewServiceClient.creatClient(NewServiceClient.java:35)
at axiomtryout.Main.main(Main.java:35)
My WSDL for test service as below
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:axis2="http://services/" xmlns:ns1="http://org.apache.axis2/xsd"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:ns0="http://services/xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
targetNamespace="http://services/">
<wsdl:documentation>TwoPara</wsdl:documentation>
<wsdl:types>
<xs:schema xmlns:ns="http://services/xsd"
attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="http://services/xsd">
<xs:element name="getValue">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="n1"
type="xs:int"/>
<xs:element minOccurs="0" name="n2"
type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getValueResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return"
nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="getValueRequest">
<wsdl:part name="parameters" element="ns0:getValue"/>
</wsdl:message>
<wsdl:message name="getValueResponse">
<wsdl:part name="parameters" element="ns0:getValueResponse"/>
</wsdl:message>
<wsdl:portType name="TwoParaPortType">
<wsdl:operation name="getValue">
<wsdl:input message="axis2:getValueRequest"
wsaw:Action="urn:getValue"/>
<wsdl:output message="axis2:getValueResponse"
wsaw:Action="urn:getValueResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="TwoParaSOAP11Binding"
type="axis2:TwoParaPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document"/>
<wsdl:operation name="getValue">
<soap:operation soapAction="urn:getValue"
style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="TwoParaSOAP12Binding"
type="axis2:TwoParaPortType">
<soap12:binding
transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="getValue">
<soap12:operation soapAction="urn:getValue"
style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="TwoParaHttpBinding"
type="axis2:TwoParaPortType">
<http:binding verb="POST"/>
<wsdl:operation name="getValue">
<http:operation location="TwoPara/getValue"/>
<wsdl:input>
<mime:content type="text/xml" part="getValue"/>
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="getValue"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="TwoPara">
<wsdl:port name="TwoParaSOAP11port_http"
binding="axis2:TwoParaSOAP11Binding">
<soap:address
location="http://localhost:8080/axis2/services/TwoPara.TwoParaSOAP11port_http/"/
(
http://localhost:8080/axis2/services/TwoPara.TwoParaSOAP11port_http/%22/
)>
</wsdl:port>
<wsdl:port name="TwoParaSOAP12port_http"
binding="axis2:TwoParaSOAP12Binding">
<soap12:address
location="http://localhost:8080/axis2/services/TwoPara.TwoParaSOAP12port_http/"/
(
http://localhost:8080/axis2/services/TwoPara.TwoParaSOAP12port_http/%22/
)>
</wsdl:port>
<wsdl:port name="TwoParaHttpport"
binding="axis2:TwoParaHttpBinding">
<http:address
location="http://localhost:8080/axis2/services/TwoPara.TwoParaHttpport/"/
( http://localhost:8080/axis2/services/TwoPara.TwoParaHttpport/%22/ )>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>