javax.xml.ws.soap.SOAPFaultException: Port does not contain
ramkrishnatripathi Dec 13, 2006 6:18 AMHi guys,
I am using jboss4.0.4GA.
I have created a webservice to add Two numbers.
After deploying the project I get CalculatorService.wsdl
Now I want to consume the webservice by client program.
After running the client program I get the following Exception:-
So Please tell me Where I am wrong??
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Endpoint {http://hello/jaws}CalculatorPort does not contain operation meta data for: {http://hello/}add at com.sun.xml.ws.encoding.soap.ClientEncoderDecoder.toMessageInfo(ClientEncoderDecoder.java:80) at com.sun.xml.ws.encoding.soap.client.SOAPXMLDecoder.toMessageInfo(SOAPXMLDecoder.java:200) at com.sun.xml.ws.protocol.soap.client.SOAPMessageDispatcher.receive(SOAPMessageDispatcher.java:549) at com.sun.xml.ws.protocol.soap.client.SOAPMessageDispatcher.doSend(SOAPMessageDispatcher.java:288) at com.sun.xml.ws.protocol.soap.client.SOAPMessageDispatcher.send(SOAPMessageDispatcher.java:153) at com.sun.xml.ws.encoding.soap.internal.DelegateBase.send(DelegateBase.java:85) at com.sun.xml.ws.client.EndpointIFInvocationHandler.implementSEIMethod(EndpointIFInvocationHandler.java:176) at com.sun.xml.ws.client.EndpointIFInvocationHandler.invoke(EndpointIFInvocationHandler.java:105) at $Proxy7.add(Unknown Source) at hello.JAXWSClient.main(JAXWSClient.java:36)
Interface
=======
package hello; import java.rmi.Remote; import java.rmi.RemoteException; import javax.ejb.Local; import javax.jws.WebMethod; import javax.jws.WebResult; import javax.jws.WebService; import javax.jws.soap.SOAPBinding; @Local @WebService @SOAPBinding(style=SOAPBinding.Style.RPC, use=SOAPBinding.Use.LITERAL) public interface CalculatorInf extends Remote{ @WebMethod(operationName="add", action="urn:add") public String add(int i, int j) throws RemoteException; }
implementaion class
====
package hello; import javax.jws.WebMethod; import javax.jws.WebResult; import javax.jws.WebService; import javax.jws.soap.SOAPBinding; import javax.ejb.Stateless; @WebService //(endpointInterface="hello.CalculatorInf") @Stateless public class Calculator implements CalculatorInf { public Calculator() {} @WebMethod(operationName="add", action="urn:add") public String add(int i, int j) { int k = i +j ; System.out.println(i + "+" + j +" = " + k); return String.valueOf(k); } }
Client Program
=========
package hello; import java.net.URL; import javax.xml.namespace.QName; import javax.xml.ws.Service; import javax.xml.rpc.*; public class JAXWSClient { static String host = "localhost"; static String portType = "Calculator"; static String serviceName = "hello-servlet"; static String serviceEndpointAddress = "http://" + host + ":8080/" + serviceName; static String nameSpace = "http://hello/jaws"; public static void main(String[] args) throws Exception { URL wsdlLocation = new URL(serviceEndpointAddress + "/" + portType + "?WSDL"); QName serviceNameQ = new QName( nameSpace, "CalculatorPort"); Service service = Service.create(wsdlLocation, serviceNameQ); CalculatorInf first = (CalculatorInf) service.getPort(serviceNameQ,hello.CalculatorInf.class); System.out.println("1: " + first.add(2, 2)); } }
WSDL
===
<definitions name="CalculatorService" targetNamespace="http://hello/jaws" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://hello/jaws" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <types> - <schema elementFormDefault="qualified" targetNamespace="http://hello/jaws" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://hello/jaws" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <complexType name="add"> - <sequence> <element name="int_1" type="int" /> <element name="int_2" type="int" /> </sequence> </complexType> - <complexType name="addResponse"> - <sequence> <element name="result" nillable="true" type="string" /> </sequence> </complexType> <element name="add" type="tns:add" /> <element name="addResponse" type="tns:addResponse" /> </schema> </types> - <message name="Calculator_add"> <part element="tns:add" name="parameters" /> </message> - <message name="Calculator_addResponse"> <part element="tns:addResponse" name="result" /> </message> - <portType name="Calculator"> - <operation name="add"> <input message="tns:Calculator_add" /> <output message="tns:Calculator_addResponse" /> </operation> </portType> - <binding name="CalculatorBinding" type="tns:Calculator"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> - <operation name="add"> <soap:operation soapAction="" /> - <input> <soap:body use="literal" /> </input> - <output> <soap:body use="literal" /> </output> </operation> </binding> - <service name="CalculatorService"> - <port binding="tns:CalculatorBinding" name="CalculatorPort"> <soap:address location="http://RAM-KRISHNA:8080/hello-servlet/Calculator" /> </port> </service> </definitions>
=============
Thanks.........