camel spring ws-从类型进行类型转换时出错:java.io.ByteArrayInputStream

时间:2018-07-08 17:39:31

标签: apache-camel spring-ws

我尝试根据站点-http://camel.apache.org/spring-web-services.html

使用骆驼和spring-ws创建Web服务

但是当我发出肥皂请求时,我得到的错误率低于

   <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
   <env:Header/>
   <env:Body>
      <env:Fault xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/">
         <faultcode>ns0:Server</faultcode>
         <faultstring xml:lang="en">Error during type conversion from type: java.io.ByteArrayInputStream to the required type: javax.xml.stream.XMLStreamReader with value java.io.ByteArrayInputStream@65422509 due java.lang.NullPointerException: charsetName</faultstring>
      </env:Fault>
   </env:Body>
</env:Envelope>

控制台异常

Caused by: java.lang.NullPointerException: charsetName
    at java.io.InputStreamReader.<init>(InputStreamReader.java:82) ~[?:1.6.0_45]
    at weblogic.xml.stax.XMLStreamInputFactory.createXMLStreamReader(XMLStreamInputFactory.java:66) ~[com.bea.core.weblogic.stax_1.10.0.0.jar:1.10.0.0]
    at org.apache.camel.converter.jaxp.StaxConverter.createXMLStreamReader(StaxConverter.java:170) ~[camel-core-2.12.2.jar:2.12.2]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_45]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[?:1.6.0_45]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[?:1.6.0_45]
    at java.lang.reflect.Method.invoke(Method.java:597) ~[?:1.6.0_45]
    at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:990) ~[camel-core-2.12.2.jar:2.12.2]
    at org.apache.camel.impl.converter.InstanceMethodTypeConverter.convertTo(InstanceMethodTypeConverter.java:78) ~[camel-core-2.12.2.jar:2.12.2]
    at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:275) ~[camel-core-2.12.2.jar:2.12.2]
    at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:113) ~[camel-core-2.12.2.jar:2.12.2]
    ... 36 more

我正在jdk 8中构建应用程序,但是在maven中将源和目标设置为1.6,因为我将仅在1.6中部署服务器中

路由器生成器和spring servlet上下文xml放在下面

@Component    
public class CamelTestServiceRoute extends RouteBuilder {
@Autowired
private TestMessageProcessor testMessageProcessor;

@Override
public void configure() throws Exception {

    //JaxbDataFormat jaxb = new JaxbDataFormat(false);
    JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
    org.apache.camel.converter.jaxb.JaxbDataFormat jxbdf = 
            new org.apache.camel.converter.jaxb.JaxbDataFormat(jaxbContext);
    //jaxb.setContextPath(jaxbContext);
    from("spring-ws:rootqname:{http://www.prxms.ws/service}CamelTestServiceRequest?endpointMapping=#camelEndpointMapper")
    .unmarshal(jxbdf)
    .process(testMessageProcessor)
    .marshal(jxbdf);
   }
}

spring servlet xml内容         

<sws:annotation-driven />

<sws:dynamic-wsdl id="testservice" portTypeName="TestService"
    locationUri="/testService/" targetNamespace="http://www.prxms.ws/definitions">
    <sws:xsd location="/schemas/service.xsd" />
</sws:dynamic-wsdl>

<camel:camelContext id="camelContext">
    <camel:contextScan />
</camel:camelContext>


<bean id="payLoadMapper"
    class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping" />

<bean id="camelEndpointMapper"
    class="org.apache.camel.component.spring.ws.bean.CamelEndpointMapping" />

<bean id="camelEndpointAdapter"
    class="org.springframework.ws.server.endpoint.adapter.MessageEndpointAdapter" />

Maven依赖

   <properties>
      <spring-ws-version>2.1.4.RELEASE</spring-ws-version>
      <camel-spring-version>2.12.2</camel-spring-version>
      <spring-test-version>3.2.4.RELEASE</spring-test-version>
      <java-version>1.6</java-version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws-core</artifactId>
            <version>${spring-ws-version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-spring-ws</artifactId>
            <version>${camel-spring-version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-jaxb</artifactId>
            <version>${camel-spring-version}</version>
        </dependency>
  <dependencies>

有人可以帮忙吗

0 个答案:

没有答案