我想在 WebLogic 10.3.6.0 中使用 EclipseLink 来使用 JAX-WS 托管 Web 服务。这在 Tomcat 中完美运行。
环境:
- Java 1.6
- WebLogic 10.3.6.0
- EclipseLink 2.4.0.v20120608-r11652
- JAXWS 2.2.7-20120813
WEB-INF/lib 包含:
- eclipselink.jar
- 快速信息集.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
- 邮件.jar
- 管理-api.jar
- mimepull.jar
- 策略.jar
- saaj-api.jar
- saaj-impl.jar
- stax-ex.jar
- stax2-api.jar
- 流缓冲.jar
- woodstox-core-asl.jar
我的代码如下:
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
}
服务: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());
return response;
}
}
Tomcat 中的完美 XML:
<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>
weblogic中的错误XML:
<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>
如果您认为我需要发布更多代码,请告诉我。
我想在 weblogic 的输出中查看 tomcat 的 XML 输出