[jboss-user] [JBossWS] - problem on invoking WS

cisco do-not-reply at jboss.com
Tue Jul 11 02:17:11 EDT 2006


I have written a WebService on JBoss 4.0.4 GA (jboss-EJB-3.0_RC8-FD + jbossws-1.0.1.GA)


  | package webservices;
  | 
  | import java.rmi.Remote;
  | 
  | public interface SimpleService extends Remote {
  |   String echo(String echo);
  | }
  | 


  | package webservices;
  | 
  | import javax.ejb.Remote;
  | import javax.ejb.Stateless;
  | import javax.jws.WebMethod;
  | import javax.jws.WebService;
  | 
  | import org.jboss.ws.annotation.PortComponent;
  | 
  | @WebService(name="EndpointInterface", targetNamespace="http://localhost", serviceName="SimpleService")
  | @PortComponent(contextRoot="/jbosswstest", urlPattern="/*")
  | @Remote(SimpleService.class)
  | @Stateless
  | public class SimpleServiceImpl implements SimpleService {
  |   @WebMethod
  |   public String echo(String input) {
  |     return input;
  |   }
  | }
  | 

After deploy it to JBoss, I got a auto-generated WSDL as follow:

  | <definitions name='SimpleService' targetNamespace='http://localhost' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://localhost' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
  |  <types>
  |   <schema elementFormDefault='qualified' targetNamespace='http://localhost' xmlns='http://www.w3.org/2001/XMLSchema' xmlns:soap11-enc='http://schemas.xmlsoap.org/soap/encoding/' xmlns:tns='http://localhost' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
  |    <complexType name='echo'>
  |     <sequence>
  |      <element name='String_1' nillable='true' type='string'/>
  |     </sequence>
  |    </complexType>
  |    <complexType name='echoResponse'>
  |     <sequence>
  |      <element name='result' nillable='true' type='string'/>
  |     </sequence>
  |    </complexType>
  |    <element name='echo' type='tns:echo'/>
  |    <element name='echoResponse' type='tns:echoResponse'/>
  |   </schema>
  |  </types>
  |  <message name='EndpointInterface_echo'>
  |   <part element='tns:echo' name='parameters'/>
  |  </message>
  |  <message name='EndpointInterface_echoResponse'>
  |   <part element='tns:echoResponse' name='result'/>
  |  </message>
  |  <portType name='EndpointInterface'>
  |   <operation name='echo'>
  |    <input message='tns:EndpointInterface_echo'/>
  |    <output message='tns:EndpointInterface_echoResponse'/>
  |   </operation>
  |  </portType>
  |  <binding name='EndpointInterfaceBinding' type='tns:EndpointInterface'>
  |   <soap:binding style='document' transport='http://schemas.xmlsoap.org/soap/http'/>
  |   <operation name='echo'>
  |    <soap:operation soapAction=''/>
  |    <input>
  |     <soap:body use='literal'/>
  |    </input>
  |    <output>
  |     <soap:body use='literal'/>
  |    </output>
  |   </operation>
  |  </binding>
  |  <service name='SimpleService'>
  |   <port binding='tns:EndpointInterfaceBinding' name='EndpointInterfacePort'>
  |    <soap:address location='http://ibm-t40:8080/jbosswstest'/>
  |   </port>
  |  </service>
  | </definitions>
  | 

Then I try to code a client to invoke the webservice:

  | package client;
  | 
  | import java.net.URL;
  | 
  | import javax.xml.namespace.QName;
  | import javax.xml.rpc.Service;
  | import javax.xml.rpc.ServiceFactory;
  | 
  | import webservices.SimpleService;
  | 
  | public class SimpleServiceClient {
  |   private static final String _namespace = "http://localhost";
  | 
  |   private static final String _service = "SimpleService";
  | 
  |   private static final String _wsdl = "http://localhost:8080/jbosswstest?wsdl";
  | 
  |   public static void main(String[] args) {
  |     try {
  |       URL defUrl = new URL(_wsdl);
  |       // Create the service factory
  |       ServiceFactory serviceFactory = ServiceFactory.newInstance();
  |       // Load the service implementation class
  |       Service remoteService = serviceFactory.createService(defUrl,
  |           new QName(_namespace, _service));
  |       // Load a proxy for our class
  |       SimpleService invoker = (SimpleService) remoteService
  |           .getPort(SimpleService.class);
  |       // Invoke our interface for each argument
  |       for (int i = 0; i < args.length; i++) {
  |         String returnedString = invoker.echo(args);
  |         System.out.println("sent string: " + args
  |             + ", received string: " + returnedString);
  |       }
  |     } catch (Exception e) {
  |       e.printStackTrace();
  |     }
  |   }
  | }
  | 

Here comes the problem ->
org.jboss.ws.WSException: Cannot obtain java type mapping for: {http://localhost}echo
  at org.jboss.ws.deployment.JSR109MetaDataBuilder.buildParameterMetaDataDoc(JSR109MetaDataBuilder.java:450)
  at org.jboss.ws.deployment.JSR109MetaDataBuilder.setupOperationsFromWSDL(JSR109MetaDataBuilder.java:200)
  at org.jboss.ws.deployment.JSR109ClientMetaDataBuilder.buildMetaDataInternal(JSR109ClientMetaDataBuilder.java:208)
  at org.jboss.ws.deployment.JSR109ClientMetaDataBuilder.buildMetaData(JSR109ClientMetaDataBuilder.java:126)
  at org.jboss.ws.deployment.JSR109ClientMetaDataBuilder.buildMetaData(JSR109ClientMetaDataBuilder.java:82)
  at org.jboss.ws.jaxrpc.ServiceImpl.(ServiceImpl.java:96)
  at org.jboss.ws.jaxrpc.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:157)
  at org.jboss.ws.jaxrpc.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:128)
  at client.SimpleServiceClient.main(SimpleServiceClient.java:24)

Could somebody give me a idea what's wrong, thanks.

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

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



More information about the jboss-user mailing list