我尝试绑定x509证书并通过客户端的webservice发送数据。 我创建了一个窗口表单应用程序并使用Microsoft.web.Service3,但是当我在本地运行此win应用程序时,它给出了一个错误,如:
身份验证失败:必须为基于签名的SOAP签名 认证。没有提供凭证。联系IT SOASvsSupport。
有人可以帮忙吗?
private void btnSubmit_Click(object sender,EventArgs e) { string certificateFile = @" C:\ XYZ \ MyTest.cer&#34 ;;
System.Security.Cryptography.X509Certificates.X509Certificate x509Certificate = new System.Security.Cryptography.X509Certificates.X509Certificate(certificateFile);
//X509Certificate x509Certificate = X509Certificate.CreateFromCertFile(certificateFile);
MyTest.DataService rdf = new MyTest.DataService();
RvsDataFeed[] rvs = rdf.GetRvsDataFeed();
txtXml.Text = "";
if (rvs != null)
{
foreach (RvsDataFeed rvsdata in rvs)
{
try
{
TrackingRequest wbttreq = new TrackingRequest();
ClientType cit = new ClientType();
cit.requestorAppName = "MMM";
cit.requestorUserName = rvsdata.ID;
wbttreq.ClientInfo = cit;
ClientWSDL.DataUtility xyzWSDL = new ClinetWSDL.DataUtility();
xyzWSDL.Url = "http://xyz.xy";
xyzWSDL.ClientCertificates.Add(x509Certificate);
txtXml.Text = txtXml.Text + Environment.NewLine + SerializeToString(td);
TrackingResponse res = new TrackingResponse();
xyzWSDL.WriteBack(wbttreq);
rdf.LogRvsDataFeedSent(rvsdata.DataFeedID);
}
catch (Exception ex)
{
txtXml.Text = txtXml.Text + Environment.NewLine + ex.Message;
}
}
}
}
答案 0 :(得分:0)
private void btnSubmit_Click(object sender,EventArgs e) { string certificateFile = @" C:\ XYZ \ MyTest.cer&#34 ;;
System.Security.Cryptography.X509Certificates.X509Certificate x509Certificate = new System.Security.Cryptography.X509Certificates.X509Certificate(certificateFile);
//X509Certificate x509Certificate = X509Certificate.CreateFromCertFile(certificateFile);
MyTest.DataService rdf = new MyTest.DataService();
RvsDataFeed[] rvs = rdf.GetRvsDataFeed();
txtXml.Text = "";
if (rvs != null)
{
foreach (RvsDataFeed rvsdata in rvs)
{
try
{
TrackingRequest wbttreq = new TrackingRequest();
ClientType cit = new ClientType();
cit.requestorAppName = "MMM";
cit.requestorUserName = rvsdata.ID;
wbttreq.ClientInfo = cit;
ClientWSDL.DataUtility xyzWSDL = new ClinetWSDL.DataUtility();
xyzWSDL.Url = "http://xyz.xy";
xyzWSDL.ClientCertificates.Add(x509Certificate);
txtXml.Text = txtXml.Text + Environment.NewLine + SerializeToString(td);
TrackingResponse res = new TrackingResponse();
xyzWSDL.WriteBack(wbttreq);
rdf.LogRvsDataFeedSent(rvsdata.DataFeedID);
}
catch (Exception ex)
{
txtXml.Text = txtXml.Text + Environment.NewLine + ex.Message;
}
}
}
}