Matt Wheeler wrote:
I am not 100% sure if this is a bug, but it appears to be. I have created a very simple web service using annotations. If I deploy it, and go to the wsdl, I notice that the location is incorrect: <wsdl:port binding="tns:Jsr181EchoServiceImplHttpBinding" name="Jsr181EchoServiceImplHttpPort"> <wsdlsoap:address location="http://localhost/services/Jsr181EchoServiceImpl"/ <http://localhost/services/Jsr181EchoServiceImpl%22/>>
</wsdl:port>
Which appears to originate in the HttpTransport class:
 public String getServiceURL( Service service )
 {
        return "http://localhost/services/"; + service.getSimpleName();
  }
You'll notice though in the XFireServletController class we provide a different version of the HttpTransport which uses the incoming server name.
I think the location should be http://localhost:8080/services/Jsr181EchoServiceImpl. When I try and test the web service with the following code (dynamic client in the documentation): String input = "garbage in - garbage out"; Client client = new Client(new URL("http://localhost:8080/petstore/services/Jsr181EchoServiceImpl?WSDL";));

Object[] results = client.invoke("echo", new Object[] {input});
 //System.out.println((String) results[0]);
 assertEquals((String) results[0], input);
I get the following stack trace: Testcase: testEchoWithDynamicClient(org.lds.petstore.ws.Jsr181EchoServiceTest): Caused an ERROR
Couldn't send message.
org.codehaus.xfire.fault.XFireFault: Couldn't send message.
 at org.codehaus.xfire.fault.XFireFault.createFault(XFireFault.java:89)
at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:30) at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:98)
 at org.codehaus.xfire.client.Client.invoke(Client.java:359)
 at org.codehaus.xfire.client.Client.invoke(Client.java:389)
at org.lds.petstore.ws.Jsr181EchoServiceTest.testEchoWithDynamicClient(Jsr181EchoServiceTest.java:37)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Caused by: org.codehaus.xfire.XFireException: Couldn't send message.
at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:179) at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:66) at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
 ... 18 more
Caused by: java.net.ConnectException: Connection refused: connect
 at java.net.PlainSocketImpl.socketConnect(Native Method)
 at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
 at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
 at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
 at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
 at java.net.Socket.connect(Socket.java:507)
 at java.net.Socket.connect(Socket.java:457)
 at java.net.Socket.<init>(Socket.java:365)
 at java.net.Socket.<init>(Socket.java:238)
at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:79) at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:121) at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:706) at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:386) at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396) at org.codehaus.xfire.transport.http.CommonsHttpMessageSender.send(CommonsHttpMessageSender.java:166) at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:168)
 ... 20 more
Also, it appears that when I navigate to the wsdl of a service that has annotations, the createPort method of Soap11Binding is called, and the transport is an instanceof WSDL11Transport, resulting in a call to getServiceUrl (included above) while if I go to the wsdl of a non-annotated service (made a service through Spring configuration) then in the createPort method, the transport is not an instanceof WSDL11Transport, and so null is returned, which results in a different location in the wsdl. However, if I test the same service as below, it succeeds: Service serviceModel = new ObjectServiceFactory().create(Jsr181EchoService.class); Jsr181EchoService service = (Jsr181EchoService) new XFireProxyFactory().create(serviceModel, "http://localhost:8080/petstore/services/Jsr181EchoServiceImpl";);
String input = "garbage in - garbage out";
String result = service.echo(input);
assertEquals(result, input);
So, I am not sure if there is an issue with dynamic client, annotations, or the way I am doing things.
Is your service really available on port 8080 and not 80? Something is refusing a connection. I would double check your ports and urls. For instance I see a "petstore" directory in your client, but not anywhere else.

Cheers,
- Dan

--
Dan Diephouse
Envoi Solutions
http://envoisolutions.com
http://netzooid.com/blog

Reply via email to