Skip to main content

Could not locate method Add : SoapFaultException

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
No replies
satheesh7134
Offline
Joined: 2011-02-18

Hi Guys,
I am new to Java and to Web services section of it. I am learning stuffs now. I have a soap message in an xml file and i need to send it to the service that can call the appropriate method.
I have pasted the WSDL and Client Code below. I am not sure whether using MessageFactory is right or not. Please check and let me know where i am going wrong.
I am getting an expection as in the subject line.
WSDL
<?xml version="1.0" encoding="UTF-8" ?>

-<<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://arthopjws/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://arthopjws/" name="ArtimeticOpsImplService">

<types />

- <message name="Add">

<part name="arg0" type="xsd:int" />

<part name="arg1" type="xsd:int" />

</message>

- <message name="AddResponse">

<part name="Addition_Result" type="xsd:int" />

</message>

- <message name="Sub">

<part name="arg0" type="xsd:int" />

<part name="arg1" type="xsd:int" />

</message>

- <message name="SubResponse">

<part name="Subtraction_Result" type="xsd:int" />

</message>

- <message name="Mul">

<part name="arg0" type="xsd:int" />

<part name="arg1" type="xsd:int" />

</message>

- <message name="MulResponse">

<part name="Multiplication_Result" type="xsd:int" />

</message>

- <message name="Div">

<part name="arg0" type="xsd:int" />

<part name="arg1" type="xsd:int" />

</message>

- <message name="DivResponse">

<part name="Division_Result" type="xsd:int" />

</message>

- <portType name="ArithmeticOps">

- <operation name="Add" parameterOrder="arg0 arg1">

<input message="tns:Add" />

<output message="tns:AddResponse" />

</operation>

- <operation name="Sub" parameterOrder="arg0 arg1">

<input message="tns:Sub" />

<output message="tns:SubResponse" />

</operation>

- <operation name="Mul" parameterOrder="arg0 arg1">

<input message="tns:Mul" />

<output message="tns:MulResponse" />

</operation>

- <operation name="Div" parameterOrder="arg0 arg1">

<input message="tns:Div" />

<output message="tns:DivResponse" />

</operation>

</portType>

- <binding name="ArtimeticOpsImplPortBinding" type="tns:ArithmeticOps">

<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" />

- <operation name="Add">

<soap:operation soapAction="" />

- <input>

<soap:body use="literal" namespace="http://arthopjws/" />

</input>

- <output>

<soap:body use="literal" namespace="http://arthopjws/" />

</output>

</operation>

- <operation name="Sub">

<soap:operation soapAction="" />

- <input>

<soap:body use="literal" namespace="http://arthopjws/" />

</input>

- <output>

<soap:body use="literal" namespace="http://arthopjws/" />

</output>

</operation>

- <operation name="Mul">

<soap:operation soapAction="" />

- <input>

<soap:body use="literal" namespace="http://arthopjws/" />

</input>

- <output>

<soap:body use="literal" namespace="http://arthopjws/" />

</output>

</operation>

+ <operation name="Div">

<soap:operation soapAction="" />

- <input>

<soap:body use="literal" namespace="http://arthopjws/" />

</input>

- <output>

<soap:body use="literal" namespace="http://arthopjws/" />

</output>

</operation>

</binding>

- <service name="ArtimeticOpsImplService">

- <port name="ArtimeticOpsImplPort" binding="tns:ArtimeticOpsImplPortBinding">

<soap:address location="http://127.0.0.1:9877/ts" />

</port>

</service>
</definitions>

Client Code
URL url = new URL("http://127.0.0.1:9877/ts?wsdl");
QName serviceName = new QName("http://arthopjws/","ArtimeticOpsImplService");
QName portName = new QName("http://arthopjws/","ArtimeticOpsImplPort");
Service service = Service.create(url, serviceName);
//ArithmeticOps eif = service.getPort(ArithmeticOps.class);

Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class,Service.Mode.MESSAGE);
SOAPMessage request = MessageFactory.newInstance().createMessage(null,new FileInputStream("C:/Users/s.krishnan.kannaiyan/Documents/NetBeansProjects/ArthOPJWS/src/arthopjws/Add.xml"));
// System.out.print(request.getContentDescription());
SOAPMessage response = dispatch.invoke(request);

The soap message has an Env, Body and Add method which has couple of arguments