Problems Using Java Web Service with .NET Client

WCF newbie here, I'm trying to get the .NET 4.0 client to use a web service hosted in JBOSS. I believe the web service results are serialized using x-fire. The client side uses WCF to connect to the service. This is in an internal web service that uses Ntlm to authenticate the caller.

I can add a service link to my client and call one of the methods on the server. I decided that the request is being sent, and the response is indeed being returned. The problem is that the answer is not in the traditional SOAP format, and I believe that standard WCF bindings cannot interpret this. Here is some information about the application:

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> 

The request is sent to the server ...

 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> 

The answer coming back from the server (pulled from the violinist) ...

 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-- 

and the error message from the .net client is as follows:

 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: ' 

the rest of the exception simply repeats the initial response from the server.

I assume that I need to create a custom binding or something like that. I looked at a good example of how to do this, but they all seem to leave something that prevents me from combining everything together. If I could handle the user binding, I would prefer to parse the answer and pass everything between the lines ------ to the WCF deserializer, as this is the actual answer to the soap.

Does anyone have any ideas on how to do this, good examples, or any other approach?

BTW, webservice is a black box, no encoding changes can be there.

Thanks.

0
source share
2 answers

Try changing the binding configuration to the following:

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

As you can see, messageEncoding is installed in Mtom, which should take care of your problem as this is what the JBoss server returns.

For a detailed description of this type of encoding, see MTOM .

+3
source

Please leave safety material

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

out of your binding. Since your messages will be protected as configured, and since the JBOSS manager model is different from the WCF manager, therefore it cannot decrypt your messages.

0
source

Source: https://habr.com/ru/post/1486883/


All Articles