我从.net连接到用java编写的wcf-service。 调用服务方法成功,但返回值不正确(它是空的,虽然它不应该是)。 我使用SoapUI测试了一个请求 - 正确工作=>问题不在服务方面。 我不知道客户端有什么问题以及如何修复它。
SoapUI生成的请求:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="SOME LINK">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>USERNAME</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">PASSWORD</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
<soapenv:Header>
<soapenv:Body>
<web:GetObjects>
<!--Optional:-->
<ObjectTypeCode>01</ObjectTypeCode>
<!--Optional:-->
<OkrugCode>1</OkrugCode>
<!--Optional:-->
<ObjectLink>true</ObjectLink>
<Offset>0</Offset>
<Limit>5</Limit>
</web:GetObjects>
</soapenv:Body>
</soapenv:Envelope>
C#-client生成的请求(从IClientMessageInspector获取)
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none" />
<VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">SMTH</VsDebuggerCausalityData>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<GetObjects xmlns="Some Link">
<ObjectTypeCode xmlns="">01</ObjectTypeCode>
<ObjectId xmlns="">0</ObjectId>
<ObjectLink xmlns="">true</ObjectLink>
<Offset xmlns="">0</Offset>
<Limit xmlns="">5</Limit>
</GetObjects>
</s:Body>
</s:Envelope>
App.Config的一部分
<bindings>
<customBinding>
<binding name="SomeConfig">
<security
authenticationMode="UserNameOverTransport"
enableUnsecuredResponse="true"
includeTimestamp="false"
defaultAlgorithmSuite="Basic256"
requireDerivedKeys="True"
messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10"/>
<textMessageEncoding messageVersion="Soap11" />
<httpsTransport maxReceivedMessageSize="2147483647"/>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="Some Link"
binding="customBinding"
bindingConfiguration="SomeConfig"
contract="SomeContact"
name="SomeName" >
</endpoint>
</client>
С#code
var someClient = new SomeServiceClient();
someClient.ClientCredentials.UserName.UserName = username;
someClient.ClientCredentials.UserName.Password = password;
someClient.Open();
var channel = someClient.ChannelFactory.CreateChannel(remoteAddress);
var objectsResponse = someClient.GetObjects(getObjectsRequest);
答案 0 :(得分:0)
解决方案是在.net客户端
中添加Security-header