使用WSSE头的Web服务 [英] Web servce with WSSE headers

查看:60
本文介绍了使用WSSE头的Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个可以使用附加请求的Web服务ASP.Net(C#)解决方案,它必须在后面的代码中完成,因为标题记录:



< soapenv:Envelope 
xmlns:max =http://training.maxmoney.co.za/webservices/maxmoney.xsd
xmlns:soapenv = http://schemas.xmlsoap.org/soap/envelope/\">
< soapenv:Header>
< wsse:Security xmlns:wsse =http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsdxmlns:wsu = http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">
< wsse:UsernameToken wsu:Id =UsernameToken-E033FC91FFC6A82CA915397704062061>
< wsse:用户名> albatross_soap< / wsse:用户名>
< wsse:密码类型=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText> @ 1B @ TR0 $$< /的wsse:密码>
< wsse:Nonce EncodingType =http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary> gNpe7bc1ArfIL0A6pAvYUQ = =< /的wsse:随机数>
< wsu:已创建> 2018-10-17T10:00:06.205Z< / wsu:已创建>
< / wsse:UsernameToken>
< / wsse:安全>
< / soapenv:标题>
< soapenv:Body>
< max:connectionTest>
< iGIDCode> 910821< / iGIDCode>
< iMleAPIKey> 4QWPiKbK4k7kvSuRAu1vrr2Mtxs< / iMleAPIKey>
< iCustomID />
< iCustomCode />
< / max:connectionTest>
< / soapenv:Body>
< / soapenv:Envelope>





回复是:



ReplyCode(4个字符)(0000 - 成功)

ReplyStr(日期和时间)



我是什么尝试过:



 string xml = doc.ToString(); 
string url =http://training.maxmoney.co.za/MaxAdmin/web_services/maxmoney/;
HttpWebRequest req =(HttpWebRequest)WebRequest.Create(url);

byte [] requestBytes = System.Text.Encoding.ASCII.GetBytes(xml);
req.Method =POST;
req.ContentType =text / xml; charset = utf-8;
req.ContentLength = requestBytes.Length;
流requestStream = req.GetRequestStream();
requestStream.Write(requestBytes,0,requestBytes.Length);
requestStream.Close();

HttpWebResponse res =(HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream(),System.Text.Encoding.Default);
string backstr = sr.ReadToEnd();

HttpContext.Current.Response.Write(backstr);
sr.Close();
res.Close();





我说得对,除了需要在XML中创建的WSSE 。

解决方案

< / wsse:密码>
< wsse:Nonce EncodingType =http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary> gNpe7bc1ArfIL0A6pAvYUQ = =< /的wsse:随机数>
< wsu:已创建> 2018-10-17T10:00:06.205Z< / wsu:已创建>
< / wsse:UsernameToken>
< / wsse:安全>
< / soapenv:标题>
< soapenv:Body>
< max:connectionTest>
< iGIDCode> 910821< / iGIDCode>
< iMleAPIKey> 4QWPiKbK4k7kvSuRAu1vrr2Mtxs< / iMleAPIKey>
< iCustomID />
< iCustomCode />
< / max:connectionTest>
< / soapenv:Body>
< / soapenv:Envelope>





回复是:



ReplyCode(4个字符)(0000 - 成功)

ReplyStr(日期和时间)



我是什么尝试过:



 string xml = doc.ToString(); 
string url =http://training.maxmoney.co.za/MaxAdmin/web_services/maxmoney/;
HttpWebRequest req =(HttpWebRequest)WebRequest.Create(url);

byte [] requestBytes = System.Text.Encoding.ASCII.GetBytes(xml);
req.Method =POST;
req.ContentType =text / xml; charset = utf-8;
req.ContentLength = requestBytes.Length;
流requestStream = req.GetRequestStream();
requestStream.Write(requestBytes,0,requestBytes.Length);
requestStream.Close();

HttpWebResponse res =(HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream(),System.Text.Encoding.Default);
string backstr = sr.ReadToEnd();

HttpContext.Current.Response.Write(backstr);
sr.Close();
res.Close();





我说得对,除了需要在XML中创建的WSSE


I am looking for a web service ASP.Net (C#) solution that can consume the attached request, it must be done in code behind, due to the header records:

<soapenv:Envelope 
  xmlns:max="http://training.maxmoney.co.za/webservices/maxmoney.xsd" 
  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
	<soapenv:Header>
		<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
			<wsse:UsernameToken wsu:Id="UsernameToken-E033FC91FFC6A82CA915397704062061">
   				<wsse:Username>albatross_soap</wsse:Username>
   				<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">@1B@tr0$$</wsse:Password>
   				<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">gNpe7bc1ArfIL0A6pAvYUQ==</wsse:Nonce>
   				<wsu:Created>2018-10-17T10:00:06.205Z</wsu:Created>
			</wsse:UsernameToken>
		</wsse:Security>
	</soapenv:Header>
   	<soapenv:Body>
      	<max:connectionTest>
         	<iGIDCode>910821</iGIDCode>
         	<iMleAPIKey>4QWPiKbK4k7kvSuRAu1vrr2Mtxs</iMleAPIKey>
        	<iCustomID/>
         	<iCustomCode/>
      	</max:connectionTest>
   	</soapenv:Body>
</soapenv:Envelope>



The Reply is:

ReplyCode (4 char) (0000 - Success)
ReplyStr (date & Time)

What I have tried:

string xml = doc.ToString();
string url = "http://training.maxmoney.co.za/MaxAdmin/web_services/maxmoney/";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);

byte[] requestBytes = System.Text.Encoding.ASCII.GetBytes(xml);
req.Method = "POST";
req.ContentType = "text/xml;charset=utf-8";
req.ContentLength = requestBytes.Length;
Stream requestStream = req.GetRequestStream();
requestStream.Write(requestBytes, 0, requestBytes.Length);
requestStream.Close();

HttpWebResponse res = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream(), System.Text.Encoding.Default);
string backstr = sr.ReadToEnd();

HttpContext.Current.Response.Write(backstr);
sr.Close();
res.Close();



And i get it right except for the WSSE that needs to be created in the XML.

解决方案

</wsse:Password> <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">gNpe7bc1ArfIL0A6pAvYUQ==</wsse:Nonce> <wsu:Created>2018-10-17T10:00:06.205Z</wsu:Created> </wsse:UsernameToken> </wsse:Security> </soapenv:Header> <soapenv:Body> <max:connectionTest> <iGIDCode>910821</iGIDCode> <iMleAPIKey>4QWPiKbK4k7kvSuRAu1vrr2Mtxs</iMleAPIKey> <iCustomID/> <iCustomCode/> </max:connectionTest> </soapenv:Body> </soapenv:Envelope>



The Reply is:

ReplyCode (4 char) (0000 - Success)
ReplyStr (date & Time)

What I have tried:

string xml = doc.ToString();
string url = "http://training.maxmoney.co.za/MaxAdmin/web_services/maxmoney/";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);

byte[] requestBytes = System.Text.Encoding.ASCII.GetBytes(xml);
req.Method = "POST";
req.ContentType = "text/xml;charset=utf-8";
req.ContentLength = requestBytes.Length;
Stream requestStream = req.GetRequestStream();
requestStream.Write(requestBytes, 0, requestBytes.Length);
requestStream.Close();

HttpWebResponse res = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream(), System.Text.Encoding.Default);
string backstr = sr.ReadToEnd();

HttpContext.Current.Response.Write(backstr);
sr.Close();
res.Close();



And i get it right except for the WSSE that needs to be created in the XML.


这篇关于使用WSSE头的Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆