我正在与拒绝为已发布的WSDL修复其方案的第三方合作。问题是 SOAP 服务需要与 WSDL 提供的不同命名空间。因此,在我的 C# 应用程序中,我在使用 .Net 代理时遇到了很多麻烦。为了解决这个问题,我只想发送一个网络请求并打包我的数据
我只是不知道如何将我的签名添加到我的请求的标头中。
Microsoft.Web.Services3.SoapEnvelope soapEnvelopeXml = new Microsoft.Web.Services3.SoapEnvelope();
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"https://Illinois-stage.tylerhost.net/efm/FilingReviewMDEPort.svc");
request.Headers.Add("SOAPAction:"urn:oasis:names:tc:legalxml-courtfiling:wsdl:WebServicesProfile-Definitions-4.0/FilingReviewMDEPort/ReviewFilingRequest"");
request.Headers.Add("Accept-Encoding: gzip, deflate");
request.KeepAlive = true;
request.Headers.Add("MIME-Version: 1.0");
request.ContentType = "multipart/related; type="application/xop+xml";start="<http://tempuri.org/0>";boundary="uuid:936f2c7e-590a-4f19-b154-ce8285adf18a+id=2";start-info="text/xml"";
request.Method = "POST";
soapEnvelopeXml.Load(@"c:tempReviewFilingRequest.xml");
System.IdentityModel.Tokens.X509SecurityToken securityToken = new System.IdentityModel.Tokens.X509SecurityToken(X509);
Microsoft.Web.Services3.Security.Tokens.X509SecurityToken signatureToken = new Microsoft.Web.Services3.Security.Tokens.X509SecurityToken(X509);
MessageSignature sig = new MessageSignature(signatureToken);
////////// XmlDocumentFragment xfrag = soapEnvelopeXml.CreateDocumentFragment();
//////////xfrag.InnerXml = messageHeader;
//////////soapEnvelopeXml.DocumentElement.FirstChild.AppendChild(xfrag);
XmlDocument xmlDoc = new XmlDocument();
MemoryStream xmlStream = new MemoryStream();
xmlDoc.Save(xmlStream);
using (var writer = XmlDictionaryWriter.CreateMtomWriter(xmlStream, Encoding.UTF8, int.MaxValue, "text/xml", "uuid:936f2c7e-590a-4f19-b154-ce8285adf18a+id=2", "http://tempuri.org/0",false,false))
{
soapEnvelopeXml.WriteTo(writer);
using (Stream stream = request.GetRequestStream())
{
stream.Write(xmlStream.ToArray(),0, xmlStream.ToArray().Length );
}
}
using (WebResponse response = request.GetResponse())
{
using (StreamReader rd = new StreamReader(response.GetResponseStream()))
{
string soapResult = rd.ReadToEnd();
Console.WriteLine(soapResult);
}
}
有几件事可能会有所帮助。
-
您收到什么错误消息?访问被拒绝(或类似的事情(?
-
您是否尝试过查看缺少哪些标题?最好的方法是下载WireShark或Telerik的Fiddler,它允许HTTPS解密。使用其中之一,您可以在互联网浏览器中访问网站并查看通过普通浏览器发送的标题。
我最终在 Node 中签名.js 切换到节点让我可以更好地控制消息。作为额外的奖金,我不必支付Microsoft税。
https://www.npmjs.com/search?q=soap&page=1&ranking=optimal