Web serv ice consumer fails to configure automaticly through
baranowb May 15, 2007 12:41 PMHey. Im relativly new to jbossws. To make it read easier.
I have very simple web service (pojo is handling requests). I have used wstool from jboss 4.0.5 GA
Here is part of my wsdl:
<?xml version="1.0" encoding="UTF-8"?> <definitions name='OperationsWService' targetNamespace='http://test.ws.gogo.java.net/' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://test.ws.gogo.java.net/' xmlns:xsd='http://www.w3.org/2001/XMLSchema'> .... <message name='Operations_sayHello'> <part name='String_1' type='xsd:string'/> </message> <message name='Operations_sayHelloResponse'> <part name='result' type='xsd:string'/> </message> .... <operation name='sayHello' parameterOrder='String_1'> <input message='tns:Operations_sayHello'/> <output message='tns:Operations_sayHelloResponse'/> </operation> .... <portType name='Operations'> ..... <operation name='sayHello' parameterOrder='String_1'> <input message='tns:Operations_sayHello'/> <output message='tns:Operations_sayHelloResponse'/> </operation> ..... </portType> ..... <operation name='sayHello'> <soap:operation soapAction=''/> <input> <soap:body namespace='http://test.ws.gogo.java.net/' use='literal'/> </input> <output> <soap:body namespace='http://test.ws.gogo.java.net/' use='literal'/> </output> </operation> ..... </binding> <service name='OperationsWService'> <port binding='tns:OperationsBinding' name='OperationsPort'> <soap:address location='REPLACE_WITH_ACTUAL_URL'/> </port> </service> </definitions>
Problem is that when wsdl is returned after GET call service is not configured.
Here is client code:
ServiceFactory factory=null; Call call =null; QName stringXmlType=new QName("http://test.ws.gogo.java.net/","String_1"); QName stringResult=new QName("http://test.ws.gogo.java.net/","result"); QName operationName = new QName("http://test.ws.gogo.java.net/", "sayHello"); factory = ServiceFactory.newInstance(); if(true) { URL wsdlLocation = new URL("http://127.0.0.1:8080/war_to_deploy/OperationsWSAction" + "?wsdl"); QName serviceName = new QName("http://test.ws.gogo.java.net/", "OperationsWService"); Service service = (Service)factory.createService(wsdlLocation, serviceName); call = service.createCall(); call.setTargetEndpointAddress("http://127.0.0.1:8080/war_to_deploy/OperationsWSAction"); call.setOperationName(operationName); //call.addParameter("String_1", stringXmlType, ParameterMode.IN); //String first = "4"; //String second = "7!"; //Integer first = new Integer(4); //Integer second= new Integer(7); //Object retObj = call.invoke(new Object[]{first, second}); }else {...}
However this code causes on the client side:
AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Client faultSubcode: faultString: Cannot find child element: String_1 faultActor: faultNode: faultDetail: {http://xml.apache.org/axis/}stackTrace:Cannot find child element: String_1
and
javax.xml.rpc.JAXRPCException: Cannot find child element: String_1 at org.jboss.ws.binding.soap.SOAPBindingProvider.getParameterFromMessage(SOAPBindingProvider.java:799) at org.jboss.ws.binding.soap.SOAPBindingProvider.unbindRequestMessage(SOAPBindingProvider.java:241) at org.jboss.ws.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:112) at org.jboss.ws.server.ServiceEndpoint.handleRequest(ServiceEndpoint.java:209) at org.jboss.ws.server.ServiceEndpointManager.processSOAPRequest(ServiceEndpointManager.java:355)
on the server side. Which is correct behaviour because message looks as follows:
<?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <ns1:sayHello soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://test.ws.gogo.java.net/"> <ns1:arg0 xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">Opuce</ns1:arg0> </ns1:sayHello> </soapenv:Body> </soapenv:Envelope>
However if clint is configured by hand it works perfectly:
ServiceFactory factory=null; Call call =null; QName stringXmlType=new QName("http://test.ws.gogo.java.net/","String_1"); QName stringResult=new QName("http://test.ws.gogo.java.net/","result"); try { QName operationName = new QName("http://test.ws.gogo.java.net/", "sayHello"); factory = ServiceFactory.newInstance(); if(false) { ..... }else { Service service = factory.createService(new QName("OperationsWService")); call= service.createCall(); call.setOperationName(operationName); call.addParameter("String_1", stringXmlType, ParameterMode.IN); call.setReturnType(stringResult,String.class); call.setTargetEndpointAddress("http://127.0.0.1:8080/war_to_deploy/OperationsWSAction"); }
What could be the problem here?
Im running WinXp Sp2
jboss 4.0.5GA
JDK1,5 update 7