[jboss-user] [JBossWS] - Re: WebServiceRef injection does not work

gsferra@imnet.it do-not-reply at jboss.com
Fri Jun 15 08:32:48 EDT 2007


anonymous wrote : 
  | To me it look like the wsrunclient simply provides a classpath for simple (i.e. Service.create) invocations
  | 

I have problems with Service.create() too using JBoss 4.0.5GA, latest EJB3 and JBossWS packages.

When I start my client I catch the following exception:

  | javax.xml.ws.WebServiceException: java.lang.IllegalArgumentException: Cannot obt
  | ain wsdl service: HelloService
  |         at javax.xml.ws.Service.create(Service.java:731)
  |         at com.imnet.oam.ws.HelloClient.<init>(HelloClient.java:13)
  |         at com.imnet.oam.ws.HelloClient.main(HelloClient.java:27)
  | Caused by: java.lang.IllegalArgumentException: Cannot obtain wsdl service: Hello
  | Service
  |         at org.jboss.ws.metadata.builder.jaxws.JAXWSClientMetaDataBuilder.buildM
  | etaDataInternal(JAXWSClientMetaDataBuilder.java:131)
  |         at org.jboss.ws.metadata.builder.jaxws.JAXWSClientMetaDataBuilder.buildM
  | etaData(JAXWSClientMetaDataBuilder.java:85)
  |         at org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.<init>(ServiceDelegat
  | eImpl.java:140)
  |         at org.jboss.ws.core.jaxws.spi.ProviderImpl.createServiceDelegate(Provid
  | erImpl.java:61)
  |         at javax.xml.ws.Service.<init>(Service.java:83)
  |         at org.jboss.ws.core.jaxws.client.ServiceExt.<init>(ServiceExt.java:60)
  |         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  | 
  |         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
  | orAccessorImpl.java:39)
  |         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
  | onstructorAccessorImpl.java:27)
  |         at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
  |         at javax.xml.ws.Service.create(Service.java:726)
  |         ... 2 more
  | 

This is the WSLD generated while deploying the EJB3 web service:

  | <definitions name='HelloService' targetNamespace='http://mypc:8080' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://mypc:8080' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
  |  <types>
  |   <xs:schema targetNamespace='http://mypc:8080' version='1.0' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
  |    <xs:element name='sayHello' nillable='true' type='xs:string'/>
  |    <xs:element name='sayHelloResponse' nillable='true' type='xs:string'/>
  |   </xs:schema>
  |  </types>
  |  <message name='Hello_sayHello'>
  |   <part element='tns:sayHello' name='sayHello'/>
  |  </message>
  |  <message name='Hello_sayHelloResponse'>
  |   <part element='tns:sayHelloResponse' name='sayHelloResponse'/>
  |  </message>
  |  <portType name='Hello'>
  |   <operation name='sayHello' parameterOrder='sayHello'>
  |    <input message='tns:Hello_sayHello'/>
  |    <output message='tns:Hello_sayHelloResponse'/>
  |   </operation>
  |  </portType>
  |  <binding name='HelloBinding' type='tns:Hello'>
  |   <soap:binding style='document' transport='http://schemas.xmlsoap.org/soap/http'/>
  |   <operation name='sayHello'>
  |    <soap:operation soapAction=''/>
  |    <input>
  |     <soap:body use='literal'/>
  |    </input>
  |    <output>
  |     <soap:body use='literal'/>
  |    </output>
  |   </operation>
  |  </binding>
  |  <service name='HelloService'>
  |   <port binding='tns:HelloBinding' name='HelloPort'>
  |    <soap:address location='http://mypc:8080/HelloService/Hello'/>
  |   </port>
  |  </service>
  | </definitions>
  | 

The client code follows:

  | package org.me.ws;
  | 
  | import java.net.URL;
  | import javax.xml.namespace.QName;
  | import javax.xml.ws.Service;
  | 
  | public class HelloClient {
  |   private static final String SERVICE_NAME = "HelloService";
  |   private static final String WSDL_LOCATION = "http://mypc:8080/HelloService/HelloService?wsdl";
  |   private Service service;
  |   
  |   public HelloClient() throws Exception {
  |     service = Service.create(new URL(WSDL_LOCATION), new QName(SERVICE_NAME));
  |   }
  |   
  |   public String getMessage() {
  |     Hello hello = null;
  |     
  |     hello = service.getPort(Hello.class);
  |     return hello.sayHello("Jim");
  |   }
  |   
  |   public static void main(String[] args) {
  |     HelloClient client = null;
  |     
  |     try {
  |       client = new HelloClient();
  |       System.out.println(client.getMessage());
  |     } catch (Throwable t) {
  |       t.printStackTrace();
  |     }
  |   }
  | }
  | 

and finally the service implementation class code follows:

  | package com.imnet.oam.ws;
  | 
  | import javax.jws.*;
  | import javax.jws.soap.SOAPBinding;
  | import javax.ejb.Stateless;
  | 
  | @Stateless
  | @WebService(name="Hello", targetNamespace="http://mypc:8080", serviceName="HelloService")
  | @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
  | public class Hello {
  |   private String message = new String("Hello, ");
  | 
  |   @WebMethod
  |   public String sayHello(String name) {
  |     return message + name + ".";
  |   }
  | }
  | 

The WSDL file is easily accessible using the internet browser or throught the http://localhost:8080/jbossws/services links. I tried to call my service in many different way, changing it's name or targetName but the results are similar. Any ideas?

Thank you

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4054722#4054722

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4054722



More information about the jboss-user mailing list