开发者

web client for web service

I've a web-service that works fine when I access them from a J2SE (desktop) application. To access this service I do follow:

  1. generate stub classes by wsdl link using java wsimport tool
  2. then I create service using generated classes and run one of wsdl operations.It looks like this:

    MyWebServiceService webService = new MyWebServiceService();

    MyWebService port = webService.getMyWebServicePort();

    webService.run("XYZ");

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:

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(ServiceDelegateIm开发者_如何学Gopl.java:202)
javax.xml.ws.Service.getPort(Service.java:143...

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.

Application server: jboss 4.2.3GA

Is it possible to connect web-service from servlet? How?

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.

Stub classes were generated using the following command:

wsimport -keep -p com.myhost.ws http://www.myhost.com/services/MyWebService?wsdl


Did you make sure your classpath does not contain multiple JAX-B Jars with differing versions ? The exception looks like a version conflict to me. Application servers usually have some kind of "endorsed" lib directory that holds JARS that are always added in front of web application classpaths. Maybe your app server has a conflicting JAX-B implementation there ?

If you use Maven to package your application, make sure transitive dependencies don't pull in unwanted JAX-B Jars (use 'mvn dependency:tree' to check this).


This definitely sounds like a JAXB conflict to me. Check out the jaxb versions that you have in your war and make sure that they are not conflicting with a jaxb jar that Jboss may have in its lib directory.


Addytionally if jbossws-native library was installed correctly the following packages should be deleted from jboss_home/lib/endorsed directory:

  • jboss-jaxrpc.jar
  • jboss-jaxws-ext.jar
  • jboss-jaxws.jar
  • jboss-saaj.jar

Otherwise you don't have ability to connect to web service through EJB or servlet.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜