我想为现有的Web服务创建一个肥皂客户端。我想,C#应该使这变得容易。我的Web服务需要使用名称空间 wsa:... 进行ws寻址,但是c#将 a:.. 发送到服务。
我找出了所有“自定义绑定”设置,例如“ Soap12WSAddressing10 ”,但它仍使用 a:... 名称空间
发送该如何解决?请帮帮我!
提前谢谢!
app.config客户端配置
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="myBinding">
<textMessageEncoding messageVersion="Soap12WSAddressing10" />
<httpsTransport manualAddressing="false" requireClientCertificate="true"/>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://blablabla.xyz"
binding="customBinding"
bindingConfiguration="myBinding" behaviorConfiguration="endpointCredentialsBehavior"
contract="dmsMock.rightContract" >
<headers>
</headers>
</endpoint>
</client>
<behaviors>
<endpointBehaviors>
<behavior name="endpointCredentialsBehavior">
<clientCredentials>
<clientCertificate findValue="Systemuser"
storeLocation="CurrentUser" storeName="My"
x509FindType="FindBySubjectName" />
<serviceCertificate>
<authentication certificateValidationMode="PeerTrust"/>
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
From1.cs发送请求
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.ServiceModel;
using System.ServiceModel.Security;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SUI_Mockclient
{
public partial class Form1 : Form
{
private void button1_Click(object sender, EventArgs e)
{
dmsMock.Client client = new dmsMock.Client();
dmsMock.ProcessAliveTestType ProcessATT = new dmsMock.ProcessAliveTestType();
client.ProcessAliveTest(ProcessATT);
}
}
}
错误的请求:ws-addressing名称空间
POST https://ws-gateway HTTP/1.1
Content-Type: application/soap+xml; charset=utf-8
Host: xyz
Content-Length: 849
Expect: 100-continue
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1"/>
<a:MessageID>urn:uuid:fbd3e030-dd89-4369-af65-aa9c56d518bf</a:MessageID>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDPo0gfhkGQrUeNhcACQAA</VsDebuggerCausalityData>
<a:To s:mustUnderstand="1">https://ws-gateway</a:To>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ProcessAliveTest xmlns="http://xmldefs.xyz"/>
</s:Body>
</s:Envelope>