0

我有来自 Java Web 服务的响应:

HTTP/1.1 200 OK
Date: Mon, 23 Apr 2012 12:08:50 GMT
Server: Jetty/5.1.14 (Linux/2.6.18-274.17.1.el5xen x86 java/1.6.0
Content-Type: text/xml; charset=utf-8
Content-Length: 571
--MIMEBoundaryurn_uuid_14B7343BF98675BB5D1335182931028
Content-Type: application/xop+xml; charset=utf-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <0.urn:uuid:14B7343BF98675BB5D1335182931029@apache.org>
<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:loginResponse xmlns:ns1="http://www.telelogic.com/change/types"><token>206398089429929753</token></ns1:loginResponse></soapenv:Body></soapenv:Envelope>
--MIMEBoundaryurn_uuid_14B7343BF98675BB5D1335182931028--

WCF 的例外告诉我The data at the root level is invalid. Line 1, position 1.

我的 app.config 如下:

<customBinding>
  <binding>
    <!--<messageModifier />-->
    <!--<mtomMessageEncoding messageVersion="Soap11" writeEncoding="utf-8" />-->
    <textMessageEncoding writeEncoding="utf-8" messageVersion="Soap11"   />
    <httpsTransport
      requireClientCertificate="false"
      transferMode="Buffered" />
  </binding>
</customBinding>

如您所见,我已经尝试了不同的设置,例如 mtom/text 编码、soap11/soap12 用于消息版本、缓冲和 responseStreamed 用于传输模式。我有点卡住了。当我用 Fiddler 剥离一些响应时,我得到了它的工作:

HTTP/1.1 200 OK
Date: Mon, 23 Apr 2012 14:21:44 GMT
Server: Jetty/5.1.14 (Linux/2.6.18-274.17.1.el5xen x86 java/1.6.0
Content-Type: text/xml; charset=utf-8
Content-Length: 571

<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:loginResponse xmlns:ns1="http://www.telelogic.com/change/types"><token>206398089429929753</token></ns1:loginResponse></soapenv:Body></soapenv:Envelope>

我错过了什么吗?我需要配置设置的神奇组合吗?

我还尝试了 IClientMessageFormatter 和 IClientMessageInspector bot,但它们在堆栈中似乎都太高了,因为 WCF 已经失败并显示 ProtocolException The data at the root level is invalid. Line 1, position 1.

我从WCF 示例中加入了 ChannelMessageInterceptor 。我以为我可以正常工作,但现在我从 java 服务中得到了异常:

HTTP/1.1 500 Internal Server Error
Date: Mon, 23 Apr 2012 14:40:05 GMT
Server: Jetty/5.1.14 (Linux/2.6.18-274.17.1.el5xen x86 java/1.6.0
Content-Type: multipart/related; boundary=MIMEBoundaryurn_uuid_14B7343BF98675BB5D1335192006387; type="application/xop+xml"; start="<0.urn:uuid:14B7343BF98675BB5D1335192006388@apache.org>"; start-info="application/soap+xml"; action="http://www.telelogic.com/change/ChangeService/login/Fault/LoginFault";charset=UTF-8
Content-Length: 2853

--MIMEBoundaryurn_uuid_14B7343BF98675BB5D1335192006387
Content-Type: application/xop+xml; charset=utf-8; type="application/soap+xml"
Content-Transfer-Encoding: binary
Content-ID: <0.urn:uuid:14B7343BF98675BB5D1335192006388@apache.org>

<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><soapenv:Fault xmlns:axis2ns15="http://www.w3.org/2003/05/soap-envelope"><soapenv:Code><soapenv:Value>axis2ns15:MustUnderstand</soapenv:Value></soapenv:Code><soapenv:Reason><soapenv:Text xml:lang="en-US">Must Understand check failed for header http://www.w3.org/2005/08/addressing : Action</soapenv:Text></soapenv:Reason><soapenv:Detail><Exception>org.apache.axis2.AxisFault: Must Understand check failed for header http://www.w3.org/2005/08/addressing : Action
    at org.apache.axis2.engine.AxisEngine.checkMustUnderstand(AxisEngine.java:88)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:137)
    at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
    at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:121)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
    at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:830)
    at compressionFilters.CompressionFilter.doFilter(CompressionFilter.java:192)
    at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:821)
    at com.telelogic.cs.filters.StrutsCharsetFilter.doFilter(StrutsCharsetFilter.java:44)
    at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:821)
    at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:471)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:568)
    at org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
    at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:633)
    at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
    at org.mortbay.http.HttpServer.service(HttpServer.java:909)
    at org.mortbay.http.HttpConnection.service(HttpConnection.java:820)
    at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:986)
    at org.mortbay.http.HttpConnection.handle(HttpConnection.java:837)
    at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:245)
    at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
    at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
</Exception></soapenv:Detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>
--MIMEBoundaryurn_uuid_14B7343BF98675BB5D1335192006387--

至少它告诉我他们正在使用 Axis?我还看到异常消息告诉我响应的内容类型与绑定中的类型不匹配,但我目前无法重现它们。

看起来很像这个问题。我还尝试了带有附件编码器的 WCF Soap,但它也一直在唠叨Data at the root level is invalid. Line 1, position 1.(但现在直接在 XmlException 而不是 ProtocolException 内)。

更新 我有 WCF SWA 工作!

包含附件的示例消息:

HTTP/1.1 200 OK
Date: Tue, 24 Apr 2012 11:27:40 GMT
Server: Jetty/5.1.14 (Linux/2.6.18-274.17.1.el5xen x86 java/1.6.0
Content-Type: multipart/related; boundary=MIMEBoundaryurn_uuid_14B7343BF98675BB5D1335266861287; type="application/xop+xml"; start="<0.urn:uuid:14B7343BF98675BB5D1335266861289@apache.org>"; start-info="text/xml";charset=UTF-8
Content-Length: 81847

--MIMEBoundaryurn_uuid_14B7343BF98675BB5D1335266861287
Content-Type: application/xop+xml; charset=utf-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <0.urn:uuid:14B7343BF98675BB5D1335266861289@apache.org>

<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:downloadAttachmentResponse xmlns:ns1="http://www.telelogic.com/change/types"><attachmentContents><xop:Include href="cid:1.urn:uuid:14B7343BF98675BB5D1335266861290@apache.org" xmlns:xop="http://www.w3.org/2004/08/xop/include"></xop:Include></attachmentContents></ns1:downloadAttachmentResponse></soapenv:Body></soapenv:Envelope>
--MIMEBoundaryurn_uuid_14B7343BF98675BB5D1335266861287
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID: <1.urn:uuid:14B7343BF98675BB5D1335266861290@apache.org>

��ࡱ�����������������>����   ����������������������������������������������������������������������������������������������������������������������������������������������
--MIMEBoundaryurn_uuid_14B7343BF98675BB5D1335266861287--

目前我正在考虑使用 HttpWebRequest 调用服务,因为解析更不容易出错。

当对这个特定消息使用默认的 MTOM 编码器时,它可以工作:S 现在我需要动态切换编码器?!

我终于让它工作了。基于 WCF SWA 示例,我创建了一个绑定扩展,它使用 TextMessageEncodingBindingElement 作为默认值,并在接收多部分/相关消息时使用 MtomMessageEncodingBindingElement 发送消息和回退机制。

谢谢你们。

4

3 回答 3

1

确保 Action Header (incoming from Java) 不为空,或应用 WCF ServiceBehavior – AddressFilterMode。

于 2012-04-23T20:42:14.210 回答
1

此肥皂的格式类似于 mime 消息,但实际上没有附件。如果您有包含附件的示例,请发布。Otehrwise 我认为 tehre 永远不是附件,我建议您构建自己的消息编码器,该编码器只需剥离除肥皂信封之外的所有内容。

于 2012-04-23T20:57:35.920 回答
0

轴需要SOAPAction:foo标题。不要问我为什么,'foo' 可以是(据我所知)任何东西,无论调用的是什么服务。但如果那不存在,它将出错。因此,如果您将其添加到第二次尝试中,可能会解决您的问题。

YMMV,我只需要在单个客户端站点处理 Axis 托管的 Java 服务,但所有这些服务都是这样的。

于 2012-04-23T20:49:00.090 回答