Error accessing Web service
mehdibr Jul 3, 2007 2:37 PMHello !
I'm french, so excuse my possible langage faults ! :)
I created an EJB 3 session bean and deployed it as a web service. Everything looks working great. I've tried it in a Web Service Explorer.
This is my WSDL
? <definitions name="HelloBeanService" targetNamespace="http://ws.cdam.clemessy.com/jaws"> ? <types> ? <schema elementFormDefault="qualified" targetNamespace="http://ws.cdam.clemessy.com/jaws"> ? <complexType name="hello"> ? <sequence> <element name="String_1" nillable="true" type="string"/> </sequence> </complexType> ? <complexType name="helloResponse"> ? <sequence> <element name="result" nillable="true" type="string"/> </sequence> </complexType> <element name="hello" type="tns:hello"/> <element name="helloResponse" type="tns:helloResponse"/> </schema> </types> ? <message name="HelloBean_helloResponse"> <part element="tns:helloResponse" name="result"/> </message> ? <message name="HelloBean_hello"> <part element="tns:hello" name="parameters"/> </message> ? <portType name="HelloBean"> ? <operation name="hello"> <input message="tns:HelloBean_hello"/> <output message="tns:HelloBean_helloResponse"/> </operation> </portType> ? <binding name="HelloBeanBinding" type="tns:HelloBean"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> ? <operation name="hello"> <soap:operation soapAction=""/> ? <input> <soap:body use="literal"/> </input> ? <output> <soap:body use="literal"/> </output> </operation> </binding> ? <service name="HelloBeanService"> ? <port binding="tns:HelloBeanBinding" name="HelloBeanPort"> <soap:address location="http://bureau:8080/EJBWS2/HelloBean"/> </port> </service> </definitions>
The problem comes with the client, here is the code
URL wsdlLocation; try { wsdlLocation = new URL("http://bureau:8080/EJBWS2/HelloBean?wsdl"); QName serviceNameQ = new QName( "http://ws.cdam.clemessy.com/jaws", "HelloBeanService"); // dynamic service usage Service service = Service.create(wsdlLocation, serviceNameQ); //String namespace = "http://ws.cdam.clemessy.com/jaws"; //String portName = "HelloBeanPort"; //QName portQN = new QName(namespace, portName); //HelloBean proxy = service.getPort(portQN, HelloBean.class); HelloBean proxy = service.getPort(HelloBean.class); //HelloBean proxy = service.getPort(serviceNameQ,HelloBean.class); /* Iterator<QName> itPort = service.getPorts(); // Iterate trough the ports while (itPort.hasNext()) { // For each port in WSDL QName port = itPort.next(); System.out.println("port : "+port); HelloBean proxy = service.getPort(port,HelloBean.class); }*/ } catch (MalformedURLException ex) { ex.printStackTrace(); }
and i have the following error
Exception in thread "main" No corresponding port found for the service interface com.clemessy.cdam.ws.HelloBean in http://bureau:8080/EJBWS2/HelloBean?wsdl at com.sun.xml.ws.client.ServiceContextBuilder.processAnnotations(ServiceContextBuilder.java:110) at com.sun.xml.ws.client.ServiceContextBuilder.completeServiceContext(ServiceContextBuilder.java:85) at com.sun.xml.ws.client.WSServiceDelegate.processServiceContext(WSServiceDelegate.java:114) at com.sun.xml.ws.client.WSServiceDelegate.createEndpointIFBaseProxy(WSServiceDelegate.java:266) at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:162) at javax.xml.ws.Service.getPort(Service.java:120) at clientejbws2.Main.main(Main.java:48)
If someone has a solution, I would be grateful !
Thanks in advance.
Best regards.