繁体   English   中英

.NET客户端无法正常使用Java Web Service

[英]Trouble Consuming Java Web Service with .NET Client

在这里是WCF新手,我正在尝试让.NET 4.0客户端使用JBOSS中托管的Web服务。 我相信Web服务的结果正在使用x-fire进行序列化。 客户端使用WCF连接到服务。 这是使用Ntlm对调用方进行身份验证的内部Web服务中的。

我能够向我的客户端添加服务引用,并调用服务器上的方法之一。 我确定正在发送请求,并且确实返回了响应。 问题在于响应不是采用传统的SOAP格式,我相信标准WCF绑定无法解释这一点。 以下是有关该应用的一些信息:

app.config

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
          <binding name="myBinding" >
            <security mode="TransportCredentialOnly">
              <transport clientCredentialType="Ntlm" proxyCredentialType="None"
                  realm="" />
              <message clientCredentialType="UserName" algorithmSuite="Default"  />
            </security>
          </binding>
        </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://server/services/WS" binding="basicHttpBinding"
          bindingConfiguration="myBinding" contract="myContract"
          name="myEndpoint" />
    </client>
  </system.serviceModel>

请求正在发送到服务器...

POST http://server/services/WS HTTP/1.1
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
Accept-Encoding: gzip, deflate,gzip, deflate,gzip, deflate
Authorization: NTLM
Host: server
Content-Length: 145

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><getAppInfo xmlns="http://ws.application.com"/></s:Body></s:Envelope>

来自服务器的响应(从提琴手那里拉回来)...

HTTP/1.1 200 OK
Connection: close
Date: Mon, 18 Jun 2012 19:48:04 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1
Set-Cookie: blah; Path=/
Content-Type: multipart/related; type="application/xop+xml"; start="<soap.xml@xfire.codehaus.org>"; start-info="text/xml";      boundary="----=_Part_14_20837339.1340048884628";charset=UTF-8


------=_Part_14_20837332219.1340048884628
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: 8bit
Content-ID: <soap.xml@xfire.codehaus.org>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><getAppInfoResponse xmlns="http://ws.app.com"><out><apiVersion xmlns="http://dto.ws.app.com">55</apiVersion><dbBuildNumber xmlns="http://dto.ws.app.com">12312</dbBuildNumber><appBuildNumber xmlns="http://dto.ws.app.com" xsi:nil="true" /></out></getAppInfoResponse></soap:Body></soap:Envelope>
------=_Part_14_20837332219.1340048884628--

和来自.net客户端的错误消息如下...

The content type multipart/related; type="application/xop+xml"; start="<soap.xml@xfire.codehaus.org>"; start-info="text/xml";       boundary="----=_Part_14_20837332219.1340048884628";charset=UTF-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 738 bytes of the response were: '

其余的异常仅重复服务器的初始响应。

我的猜测是我需要进行自定义绑定或类似的操作。 我到处找了一个很好的例子来说明如何执行此操作,但是它们似乎都遗漏了一些东西,使我无法将所有内容连接在一起。 如果我可以使自定义绑定正常工作,我的猜测将是解析响应,并将------行之间的所有内容传递给WCF解串器,因为这是实际的肥皂响应。

是否有人对如何执行此操作有任何想法,可以遵循的良好示例或完全不同的方法?

顺便说一句,Web服务是一个黑匣子,在此处不会发生任何编码更改。

谢谢。

尝试将绑定配置更改为以下内容:

<binding name="myBinding" messageEncoding="Mtom">

如您所见,messageEncoding设置为Mtom,这应该解决您的问题,因为这是JBoss服务器返回的内容。

有关此编码类型的详细说明,请参见MTOM

请忽略安全性内容

<security mode="TransportCredentialOnly">
              <transport clientCredentialType="Ntlm" proxyCredentialType="None"
                  realm="" />
              <message clientCredentialType="UserName" algorithmSuite="Default"  />
            </security>

从您的绑定。 因为将根据设置保护您的消息,并且JBOSS调度程序模型与WCF调度程序不同,所以它无法解密您的消息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM