java - How to get EclipseLink MOXy working in WebLogic in a JAX-WS based web service? -
java - How to get EclipseLink MOXy working in WebLogic in a JAX-WS based web service? -
i want utilize eclipselink in weblogic 10.3.6.0 host web-services using jax-ws. works in tomcat.
environment:
java 1.6 weblogic 10.3.6.0 eclipselink 2.4.0.v20120608-r11652 jaxws 2.2.7-20120813web-inf/lib contains:
eclipselink.jar fastinfoset.jar gmbal-api-only.jar ha-api.jar javax.annotation.jar jaxb-api.jar jaxb-impl.jar jaxb-xjc.jar jaxws-api.jar jaxws-eclipselink-plugin.jar jaxws-rt.jar jaxws-tools.jar jsr181-api.jar mail.jar management-api.jar mimepull.jar policy.jar saaj-api.jar saaj-impl.jar stax-ex.jar stax2-api.jar streambuffer.jar woodstox-core-asl.jarmy code follows:
testrequestdto.java
@xmlaccessortype(xmlaccesstype.field) @xmlrootelement(name = "test_request") public class testrequestdto implements serializable { @xmlpath("request/name/text()") private string requestname; @xmlpath("request/value/text()") private string requestvalue; //getter setters }
testresponsedto.java
@xmlaccessortype(xmlaccesstype.field) @xmlrootelement(name = "test_response") public class testresponsedto implements serializable { @xmlpath("response/name/text()") private string responsename; @xmlpath("response/value/text()") private string responsevalue; //getter setters }
the service: sampletest.java
@webservice public class sampletest { @webmethod public testresponsedto fetchresponse(testrequestdto request) { system.out.println("request.getrequestname()" + request.getrequestname()); system.out.println("request.getrequestvalue()" + request.getrequestvalue()); testresponsedto response = new testresponsedto(); response.setresponsename("service response"); response.setresponsevalue(new date().tostring()); homecoming response; } }
perfect xml in tomcat:
<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://service.test.services.com/" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> <soapenv:body> <q0:fetchresponse> <arg0> <request> <name>this-that</name> <value>home-run</value> </request> </arg0> </q0:fetchresponse> </soapenv:body> </soapenv:envelope> <s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:body> <ns0:fetchresponseresponse xmlns:ns0="http://service.test.services.com/"> <return> <response> <name>service response</name> <value>wed feb 06 20:21:13 xxx 2013</value> </response> </return> </ns0:fetchresponseresponse> </s:body> </s:envelope>
wrong xml in weblogic:
<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://service.test.services.com/" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> <soapenv:body> <q0:fetchresponse> <arg0> <requestname>hello</requestname> <requestvalue>wassup</requestvalue> </arg0> </q0:fetchresponse> </soapenv:body> </soapenv:envelope> <s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:body> <ns2:fetchresponseresponse xmlns:ns2="http://service.test.services.com/"> <return> <responsename>service response</responsename> <responsevalue>wed feb 06 20:30:06 ist 2013</responsevalue> </return> </ns2:fetchresponseresponse> </s:body> </s:envelope>
if think need set out more code, please allow me know.
i want see xml output tomcat in output weblogic
the jax-ws implementation in weblogic 10.3.6 hard coded utilize jaxb reference implementation. eclipselink jaxb (moxy) default jaxb provider of weblogic 12.1.1 , can leverage of our extensions in jax-ws web services:
http://blog.bdoughan.com/2011/12/eclipselink-moxy-is-jaxb-provider-in.htmlfor jax-ws implementations not provide integration moxy jaxb provider leverage javax.xml.ws.provider
interface instead of traditional service endpoint interface. provider gives access actual xml message. access xml message can interact straight using moxy.
import javax.xml.bind.*; import javax.xml.bind.util.jaxbsource; import javax.xml.transform.source; import javax.xml.ws.*; @servicemode(service.mode.payload) @webserviceprovider( portname = "findcustomerport", servicename = "findcustomerservice", targetnamespace = "http://service.jaxws.blog/", wsdllocation = "web-inf/wsdl/findcustomerservice.wsdl") public class findcustomerservice implements provider<source> { private jaxbcontext jaxbcontext; public findcustomerservice() { seek { jaxbcontext = jaxbcontext.newinstance(findcustomerresponse.class, findcustomerrequest.class); } grab (jaxbexception e) { throw new webserviceexception(e); } } @override public source invoke(source request) throws webserviceexception { seek { unmarshaller unmarshaller = jaxbcontext.createunmarshaller(); findcustomerrequest fcrequest = (findcustomerrequest) unmarshaller .unmarshal(request); client customer = new customer(); customer.setid(fcrequest.getarg0()); customer.setfirstname("jane"); customer.setlastname("doe"); findcustomerresponse response = new findcustomerresponse(); response.setvalue(customer); homecoming new jaxbsource(jaxbcontext, response); } grab (jaxbexception e) { throw new webserviceexception(e); } } }
for more information
http://blog.bdoughan.com/2013/02/leveraging-moxy-in-your-web-service-via.html how utilize moxy xpath annotated beans in web services? java jax-ws eclipselink weblogic-10.x moxy
Comments
Post a Comment