title: web client for web service
body: <p>I've a web-service that works fine when I access them from a J2SE (desktop) application. To access this service I do follow:</p>
  
  <ol>
  <li>generate stub classes by wsdl link using java wsimport tool</li>
  <li><p>then I create service using generated classes and run one of wsdl operations.It looks like this:</p>
  
  <p>MyWebServiceService webService = new MyWebServiceService();</p>
  
  <p>MyWebService port = webService.getMyWebServicePort();</p>
  
  <p>webService.run("XYZ");</p></li>
  </ol>
  
  <p>As I sad it work fine when I use it in a standalone application.
  But...when I try to access web-service in the same way but from servlet-client, using generated stubs I get following error:</p>
  
  <pre><code>java.lang.ClassCastException: com.sun.xml.bind.v2.runtime.JAXBContextImpl cannot be cast to com.sun.xml.bind.api.JAXBRIContext
  org.jboss.ws.metadata.umdm.EndpointMetaData.eagerInitializeAccessors(EndpointMetaData.java:686)
  org.jboss.ws.metadata.umdm.EndpointMetaData.initializeInternal(EndpointMetaData.java:567)
  org.jboss.ws.metadata.umdm.EndpointMetaData.eagerInitialize(EndpointMetaData.java:553)
  org.jboss.ws.metadata.builder.jaxws.JAXWSClientMetaDataBuilder.rebuildEndpointMetaData(JAXWSClientMetaDataBuilder.java:314)
  org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.getPortInternal(ServiceDelegateImpl.java:271)
  org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.getPort(ServiceDelegateImpl.java:202)
  javax.xml.ws.Service.getPort(Service.java:143...
  </code></pre>
  
  <p>I've searched google long time but found nothing helpful topics. Some topics show examples accessing web-services from servlet, but unfortunately I can't do this...( And don't know what is cause of trouble.</p>
  
  <p>Application server: jboss 4.2.3GA</p>
  
  <p>Is it possible to connect web-service from servlet? How?</p>
  
  <p>I've tried use @WebServiceRef annotation, but it seem web-container can't inject web-service stub. And I think that container must not do this itself, because stub classes have already been generated by wsimport tool, and its enouph to use this classes for accessing of web-service.</p>
  
  <p>Stub classes were generated using the following command:</p>
  
  <pre><code>wsimport -keep -p com.myhost.ws http://www.myhost.com/services/MyWebService?wsdl
  </code></pre>