我正在尝试在SoapUI中创建一个示例请求,但是我不确定如何使它工作。
这是C#中的有效示例:
var myService = new MyServiceClient("WSHttpBinding_MyService");
myService .ClientCredentials.UserName.UserName = "User";
myService .ClientCredentials.UserName.Password = "Password";
var response = myService.MyMethod("parameter1");
配置:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IMyService">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://myWebsite.com:8000/MyService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMyService"
contract="MyService.IMyService" name="WSHttpBinding_IMyService" />
</client>
</system.serviceModel>
在SoapUI中使它工作似乎并不难,但我不断遇到各种错误。
有人对此有一个可行的例子吗?
答案 0 :(得分:1)
双击端点信息以进入客户端端点的属性,添加用户名/密码凭证,并将WSS-Type更改为 PasswordText 。如下图所示。
此外,由于传输层的安全性,我们应该在客户端调用服务器的证书时,将服务器的证书安装在受信任的根证书颁发机构中。
随时告诉我是否有什么可以帮助的。
答案 1 :(得分:1)
通过在wcf配置中禁用'EstablishmentSecurityContext'解决了该问题。之后,SoapUI可以拨打电话。
配置:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IMyService">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" negotiateServiceCredential="true"
establishSecurityContext="false" algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://myWebsite.com:8000/MyService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMyService"
contract="MyService.IMyService" name="WSHttpBinding_IMyService" />
</client>
</system.serviceModel>
然后在SoapUI中选中wsa:To框以使其正常运行: