Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.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 从soap请求中删除可选标记时失败_Java_Spring_Soap_Xsd_Spring Ws - Fatal编程技术网

Java 从soap请求中删除可选标记时失败

Java 从soap请求中删除可选标记时失败,java,spring,soap,xsd,spring-ws,Java,Spring,Soap,Xsd,Spring Ws,正如标题中所建议的,我从请求中删除可选参数时出错 完整请求: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v001="http://xmlns.tel.be/nin/v001"> <soapenv:Header/> <soapenv:Body> <v001:Request> <v0

正如标题中所建议的,我从请求中删除可选参数时出错

完整请求:

 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v001="http://xmlns.tel.be/nin/v001">
   <soapenv:Header/>
   <soapenv:Body>
      <v001:Request>
         <v001:locationId>lyuda_0309001_loc</v001:locationId>
         <v001:workOrderId>88155530</v001:workOrderId>
         <v001:systemName>NINAS</v001:systemName>
         <v001:scenarioId>2</v001:scenarioId>
         <!--Optional:-->
         <v001:scenarioData>
            <v001:scenarioData></v001:scenarioData>
         </v001:scenarioData>
      </v001:Request>
   </soapenv:Body>
</soapenv:Envelope>

lyuda_0309001_loc
88155530
尼纳斯
2.
当我把它叫做

             <v001:scenarioData>
                <v001:scenarioData></v001:scenarioData>
             </v001:scenarioData>

一切都好 但是当我尝试删除可选标记时

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v001="http://xmlns.tel.be/nin/v001">
   <soapenv:Header/>
   <soapenv:Body>
      <v001:NinasNCOssRequest>
         <v001:locationId>lyuda_0309001_loc</v001:locationId>
         <v001:workOrderId>88155531</v001:workOrderId>
         <v001:systemName>NINAS</v001:systemName>
         <v001:scenarioId>2</v001:scenarioId>
      </v001:NinasNCOssRequest>
   </soapenv:Body>
</soapenv:Envelope>

lyuda_0309001_loc
88155531
尼纳斯
2.
打个电话我有个毛病:

<Error> <org.springframework.ws.soap.server.SoapMessageDispatcher> <devapp104.netcracker.com> <clust1> <[ACTIVE] ExecuteThread: '14' for queue: 'weblogic.kernel.Default (self-tuning)'> <guest> <> <> <1442316335622> <BEA-000000> <ERROR org.springframework.ws.soap.server.SoapMessageDispatcher - EndpointInterceptor.afterCompletion threw exception
org.springframework.oxm.UnmarshallingFailureException: JAXB unmarshalling exception; nested exception is javax.xml.bind.UnmarshalException: unexpected element (uri:"http://schemas.xmlsoap.org/soap/envelope/", local:"Fault"). Expected elements are <{http://xmlns.tel.be/nin/v001}Request>,<{http://xmlns.tel.be/nin/v001}Response>,<{http://xmlns.tel.be/nin/v001}ScenarioEnum>,<{http://xmlns.tel.be/nin/v001}ValidationException>
    at org.springframework.oxm.jaxb.Jaxb2Marshaller.convertJaxbException(Jaxb2Marshaller.java:863)
    at org.springframework.oxm.jaxb.Jaxb2Marshaller.unmarshal(Jaxb2Marshaller.java:742)
    at org.springframework.oxm.jaxb.Jaxb2Marshaller.unmarshal(Jaxb2Marshaller.java:720)
    at com.net.tel.interceptors.AttachmentInterceptor.afterCompletion(AttachmentInterceptor.java:46)
    at org.springframework.ws.server.endpoint.interceptor.DelegatingSmartEndpointInterceptor.afterCompletion(DelegatingSmartEndpointInterceptor.java:90)
    at org.springframework.ws.server.MessageDispatcher.triggerAfterCompletion(MessageDispatcher.java:399)
    at org.springframework.ws.server.MessageDispatcher.dispatch(MessageDispatcher.java:249)
    at org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:173)
    at org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:88)
    at org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:59)
    at org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:239)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:184)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3732)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Caused by: javax.xml.bind.UnmarshalException: unexpected element (uri:"http://schemas.xmlsoap.org/soap/envelope/", local:"Fault"). Expected elements are <{http://xmlns.tel.be/nin/v001}Request>,<{http://xmlns.tel.be/nin/v001}Response>,<{http://xmlns.tel.be/nin/v001}ScenarioEnum>,<{http://xmlns.tel.be/nin/v001}ValidationException>
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:663)
    at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:258)
    at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:253)
    at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:120)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(UnmarshallingContext.java:1064)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:499)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:480)
    at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.startElement(InterningXmlVisitor.java:75)
    at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:150)
    at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:244)
    at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:127)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:322)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:305)
    at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:127)
    at org.springframework.oxm.jaxb.Jaxb2Marshaller.unmarshal(Jaxb2Marshaller.java:738)
    ... 27 more
> 

请求的xsd架构:

<xsd:element name="NinasNCOssRequest" type="RequestType"/>

<xsd:complexType name="RequestType">
        <xsd:sequence>
            <xsd:element name="locationId" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="false"/>
            <xsd:element name="workOrderId" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="false"/>
            <xsd:element name="systemName" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="false"/>
            <xsd:element name="scenarioId" type="schema:ScenarioType" minOccurs="1" maxOccurs="1" nillable="false"/>
            <xsd:element name="scenarioData" type="schema:ScenarioDataType" minOccurs="0" maxOccurs="1" nillable="false" />
        </xsd:sequence>
    </xsd:complexType>

<xsd:simpleType name="ScenarioType">
        <xsd:restriction base="xsd:int">
            <xsd:enumeration value="1"/>
            <xsd:enumeration value="2"/>
        </xsd:restriction>
    </xsd:simpleType>

<xsd:complexType name="ScenarioDataType">
        <xsd:sequence>
            <xsd:element name="scenarioData" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>


有什么提示可以解决这个问题吗?

最初,我认为您有一个验证异常,因此我询问了您的XSD模式文件。然而,这是不正确的

你展示了:

<Error> <org.springframework.ws.soap.server.SoapMessageDispatcher> <devapp104.netcracker.com> <clust1> <[ACTIVE] ExecuteThread: '14' for queue: 'weblogic.kernel.Default (self-tuning)'> <guest> <> <> <1442316335622> <BEA-000000> <ERROR org.springframework.ws.soap.server.SoapMessageDispatcher - EndpointInterceptor.afterCompletion threw exception
org.springframework.oxm.UnmarshallingFailureException: JAXB unmarshalling exception; nested exception is javax.xml.bind.UnmarshalException: unexpected element (uri:"http://schemas.xmlsoap.org/soap/envelope/", local:"Fault"). Expected elements are <{http://xmlns.tel.be/nin/v001}Request>,<{http://xmlns.tel.be/nin/v001}Response>,<{http://xmlns.tel.be/nin/v001}ScenarioEnum>,<{http://xmlns.tel.be/nin/v001}ValidationException>
    at org.springframework.oxm.jaxb.Jaxb2Marshaller.convertJaxbException(Jaxb2Marshaller.java:863)
    at org.springframework.oxm.jaxb.Jaxb2Marshaller.unmarshal(Jaxb2Marshaller.java:742)

最初,我认为您有一个验证异常,因此我询问了您的XSD模式文件。然而,这是不正确的

你展示了:

<Error> <org.springframework.ws.soap.server.SoapMessageDispatcher> <devapp104.netcracker.com> <clust1> <[ACTIVE] ExecuteThread: '14' for queue: 'weblogic.kernel.Default (self-tuning)'> <guest> <> <> <1442316335622> <BEA-000000> <ERROR org.springframework.ws.soap.server.SoapMessageDispatcher - EndpointInterceptor.afterCompletion threw exception
org.springframework.oxm.UnmarshallingFailureException: JAXB unmarshalling exception; nested exception is javax.xml.bind.UnmarshalException: unexpected element (uri:"http://schemas.xmlsoap.org/soap/envelope/", local:"Fault"). Expected elements are <{http://xmlns.tel.be/nin/v001}Request>,<{http://xmlns.tel.be/nin/v001}Response>,<{http://xmlns.tel.be/nin/v001}ScenarioEnum>,<{http://xmlns.tel.be/nin/v001}ValidationException>
    at org.springframework.oxm.jaxb.Jaxb2Marshaller.convertJaxbException(Jaxb2Marshaller.java:863)
    at org.springframework.oxm.jaxb.Jaxb2Marshaller.unmarshal(Jaxb2Marshaller.java:742)

异常主要表明
com.net.tel.interceptors.AttachmentInterceptor
的实现中存在问题。堆栈跟踪表明这是一个端点拦截器,它试图对来自服务的响应进行一些后处理,但无法识别SOAP错误响应:它没有以不同的方式处理这些响应,而是尝试以与成功响应相同的方式解组有效负载,导致隐藏原始SOAP错误的异常


一旦您在
com.net.tel.interceptors.AttachmentInterceptor
中修复了该问题,您将得到一个有意义的SOAP错误响应,该响应可能会指示服务拒绝您的请求的原因。

异常主要指示在实现中存在问题
com.net.tel.interceptors.AttachmentInterceptor
。堆栈跟踪表明这是一个端点拦截器,它试图对来自服务的响应进行一些后处理,但无法识别SOAP错误响应:它没有以不同的方式处理这些响应,而是尝试以与成功响应相同的方式解组有效负载,导致隐藏原始SOAP错误的异常


一旦您在
com.net.tel.interceptors.AttachmentInterceptor
中解决了该问题,您将得到一个有意义的SOAP错误响应,该响应可能会指示服务拒绝您请求的原因。

添加您正在发送的请求。。。不起作用的那一个是完全不同的请求,具有不同的命名空间。。。等等。失败的请求具有
xmlns:v001=”http://xmlns.telenet.be/oss/ninas/v001“
正常的有
xmlns:v001=”http://xmlns.tel.be/nin/v001“
您的开始标签也不同。看起来你把事情弄得一团糟,当我在你的评论后添加问题时,我忘了更改路径:)现在一切都应该好了。你能把XSD中定义该元素(不仅仅是标记)的相关部分显示为可选部分吗?@Abel更新了问题添加你发送的请求。。。不起作用的那一个是完全不同的请求,具有不同的命名空间。。。等等。失败的请求具有
xmlns:v001=”http://xmlns.telenet.be/oss/ninas/v001“
正常的有
xmlns:v001=”http://xmlns.tel.be/nin/v001“
您的开始标签也不同。看起来你把事情搞混了,很抱歉,当我在你的评论后添加问题时,我忘了更改路径:)现在一切都好了。你能把XSD中定义该元素(不仅仅是标记)的相关部分显示为可选部分吗?@Abel更新了问题谢谢你的建议,我将尝试使用SoapFaultDetail调查此问题谢谢您的建议,我将尝试使用SoapFaultDetail调查此问题