Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/358.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何让EclipseLink MOXy在基于JAX-WS的web服务的WebLogic中工作?_Java_Jax Ws_Eclipselink_Weblogic 10.x_Moxy - Fatal编程技术网

Java 如何让EclipseLink MOXy在基于JAX-WS的web服务的WebLogic中工作?

Java 如何让EclipseLink MOXy在基于JAX-WS的web服务的WebLogic中工作?,java,jax-ws,eclipselink,weblogic-10.x,moxy,Java,Jax Ws,Eclipselink,Weblogic 10.x,Moxy,我想在WebLogic10.3.6.0中使用EclipseLink来使用JAX-WS托管web服务。这在Tomcat中非常有效 环境: Java 1.6 WebLogic 10.3.6.0 日食2.4.0.v20120608-r11652 JAXWS 2.2.7-20120813 WEB-INF/lib包含: 日食罐 FastInfoset.jar gmbal-api-only.jar ha-api.jar javax.annotation.jar jaxb-api.jar jaxb-im

我想在WebLogic10.3.6.0中使用EclipseLink来使用JAX-WS托管web服务。这在Tomcat中非常有效

环境:

  • Java 1.6
  • WebLogic 10.3.6.0
  • 日食2.4.0.v20120608-r11652
  • JAXWS 2.2.7-20120813
WEB-INF/lib包含:

  • 日食罐
  • 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.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>

这个那个
本垒打
服务响应
2013年2月6日星期三20:21:13 XXX
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>

你好
wassup
服务响应
2013年2月6日星期三20:30:06 IST
如果你认为我需要发布更多的代码,请告诉我


我想在weblogic的输出中看到tomcat的XML输出,weblogic 10.3.6中的JAX-WS实现是硬编码的,以使用JAXB参考实现。是WebLogic 12.1.1中的默认JAXB提供程序,您可以在JAX-WS Web服务中利用我们的所有扩展:

对于不提供与MOXy集成作为JAXB提供者的JAX-WS实现,您可以利用
javax.xml.WS.provider
接口,而不是传统的服务端点接口。提供程序允许您访问实际的XML消息。通过访问XML消息,您可以直接使用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() {
        try {
            jaxbContext = JAXBContext.newInstance(FindCustomerResponse.class,
                    FindCustomerRequest.class);
        } catch (JAXBException e) {
            throw new WebServiceException(e);
        }
    }

    @Override
    public Source invoke(Source request) throws WebServiceException {
        try {
            Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
            FindCustomerRequest fcRequest = (FindCustomerRequest) unmarshaller
                    .unmarshal(request);

            Customer customer = new Customer();
            customer.setId(fcRequest.getArg0());
            customer.setFirstName("Jane");
            customer.setLastName("Doe");

            FindCustomerResponse response = new FindCustomerResponse();
            response.setValue(customer);

            return new JAXBSource(jaxbContext, response);
        } catch (JAXBException e) {
            throw new WebServiceException(e);
        }
    }

}
import javax.xml.bind.*;
导入javax.xml.bind.util.JAXBSource;
导入javax.xml.transform.Source;
导入javax.xml.ws.*;
@服务模式(服务模式有效负载)
@WebServiceProvider(
portName=“FindCustomerPort”,
serviceName=“FindCustomerService”,
targetNamespace=”http://service.jaxws.blog/", 
wsdlLocation=“WEB-INF/wsdl/FindCustomerService.wsdl”)
公共类FindCustomerService实现提供程序{
私有JAXBContext JAXBContext;
公共FindCustomerService(){
试一试{
jaxbContext=jaxbContext.newInstance(FindCustomerResponse.class,
FindCustomerRequest.class);
}捕获(JAXBEException e){
抛出新的WebServiceException(e);
}
}
@凌驾
公共源调用(源请求)引发WebServiceException{
试一试{
Unmarshaller Unmarshaller=jaxbContext.createUnmarshaller();
FindCustomerRequest fcRequest=(FindCustomerRequest)解组器
.unmarshal(请求);
客户=新客户();
setId(fcRequest.getArg0());
customer.setFirstName(“Jane”);
customer.setLastName(“Doe”);
FindCustomerResponse=新的FindCustomerResponse();
响应。设定值(客户);
返回新的JAXBSource(jaxbContext,response);
}捕获(JAXBEException e){
抛出新的WebServiceException(e);
}
}
}
了解更多信息