Cannot obtain wsdl service (problem in JBoss 4.2 used to wor
burakbayramli Oct 16, 2007 5:05 AMI have the following code that used to work in JBoss 4.0.4GA. After port to 4.2, server complained about "context roots being different, so I added @WebContext to all web services. Now server is fine, I can see the WSDL, but I cannot connect to the server using a Java client.
@WebService @SOAPBinding(style=Style.RPC) public interface Calculator extends Remote { @WebMethod int add(int x, int y); @WebMethod int subtract(int x, int y); }
@Stateless @WebService(name="CalculatorService",serviceName="CalculatorService",endpointInterface="org.bilgidata.kitapdemo.service.Calculator") @WebContext(contextRoot="/ggServices") public class CalculatorBean implements Calculator { public int add(int x, int y) { System.out.println("inside add"); return x + y; } public int subtract(int x, int y) { System.out.println("inside subtract"); return x - y; } }
public class Client { public static void main(String[] args) throws Exception { URL url = new URL("http://localhost:8080/ggServices/CalculatorBean?wsdl"); QName qname = new QName("http://localhost:8080/ggServices/CalculatorBean", "CalculatorService"); ServiceFactory factory = ServiceFactory.newInstance(); Service service = factory.createService(url, qname); Calculator calculator = (Calculator) service.getPort(Calculator.class); System.out.println("1 + 1 = " + calculator.add(1, 1)); System.out.println("1 - 1 = " + calculator.subtract(1, 1)); } }
The WSDL looks like
<definitions name='CalculatorService' targetNamespace='http://service.kitapdemo.bilgidata.org/' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://service.kitapdemo.bilgidata.org/' xmlns:xsd='http://www.w3.org/2001/XMLSchema'> <types></types> <message name='Calculator_subtract'> <part name='arg0' type='xsd:int'></part> <part name='arg1' type='xsd:int'></part> </message> <message name='Calculator_add'> <part name='arg0' type='xsd:int'></part> <part name='arg1' type='xsd:int'></part> </message> <message name='Calculator_addResponse'> <part name='return' type='xsd:int'></part> </message> <message name='Calculator_subtractResponse'> <part name='return' type='xsd:int'></part> </message> <portType name='Calculator'> <operation name='add' parameterOrder='arg0 arg1'> <input message='tns:Calculator_add'></input> <output message='tns:Calculator_addResponse'></output> </operation> <operation name='subtract' parameterOrder='arg0 arg1'> <input message='tns:Calculator_subtract'></input> <output message='tns:Calculator_subtractResponse'></output> </operation> </portType> <binding name='CalculatorBinding' type='tns:Calculator'> <soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/> <operation name='add'> <soap:operation soapAction=''/> <input> <soap:body namespace='http://service.kitapdemo.bilgidata.org/' use='literal'/> </input> <output> <soap:body namespace='http://service.kitapdemo.bilgidata.org/' use='literal'/> </output> </operation> <operation name='subtract'> <soap:operation soapAction=''/> <input> <soap:body namespace='http://service.kitapdemo.bilgidata.org/' use='literal'/> </input> <output> <soap:body namespace='http://service.kitapdemo.bilgidata.org/' use='literal'/> </output> </operation> </binding> <service name='CalculatorService'> <port binding='tns:CalculatorBinding' name='CalculatorServicePort'> <soap:address location='http://127.0.0.1:8080/ggServices/CalculatorBean'/> </port> </service> </definitions>
Exception in thread "main" java.lang.IllegalArgumentException: Cannot obtain wsdl service: {http://localhost:8080/ggServices/CalculatorBean}CalculatorService at org.jboss.ws.metadata.builder.jaxrpc.JAXRPCClientMetaDataBuilder.buildMetaDataInternal(JAXRPCClientMetaDataBuilder.java:171) at org.jboss.ws.metadata.builder.jaxrpc.JAXRPCClientMetaDataBuilder.buildMetaData(JAXRPCClientMetaDataBuilder.java:133) at org.jboss.ws.metadata.builder.jaxrpc.JAXRPCClientMetaDataBuilder.buildMetaData(JAXRPCClientMetaDataBuilder.java:85) at org.jboss.ws.core.jaxrpc.client.ServiceImpl.<init>(ServiceImpl.java:111) at org.jboss.ws.core.jaxrpc.client.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:157) at org.jboss.ws.core.jaxrpc.client.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:128) at org.bilgidata.kitapdemo.service.Client.main(Client.java:18)