Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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:

POST http://training.maxmoney.co.za/MaxAdmin/web_services/maxmoney/ HTTP/1.1
SOAPAction: http://training.maxmoney.co.za/MaxAdmin/web_services/maxmoney/ConnectionTest
Username: XXX
Password: YYY
Content-Type: text/xml;charset="utf-8"
Host: training.maxmoney.co.za
Content-Length: 1227
Expect: 100-continue
Connection: Keep-Alive

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:max="http://training.maxmoney.co.za/webservices/maxmoney.xsd">
   <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>XXX</wsse:Username>
   				<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">YYY</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>ZZZ</iMleAPIKey>
         <iCustomID/>
         <iCustomCode/>
      </max:connectionTest>
   </soapenv:Body>
</soapenv:Envelope>


The Reply is:

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

What I have tried:

I have tried the below:

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();


But I get a document does not exist.
The XML runs fine in SOAPUI
Posted
Updated 22-May-19 6:10am
v3
Comments
Richard MacCutchan 21-May-19 4:58am    
It looks to me like there is something missing from the end of the URL. In your SOAP sample you have ConnectionTest at the end.
Member 9374423 22-May-19 2:33am    
that is the test url, the wsdl file is at :

http://training.maxmoney.co.za/MaxAdmin/web_services/?.wsdl

But i cant get that to work either

Also I cant add it using the "Add web service" because there are header records
lmoelleb 3-Jun-19 14:55pm    
Any reason you can't use WCF and read the headers like specified here: https://stackoverflow.com/questions/18877591/how-to-read-http-request-headers-in-a-wcf-web-service - while my hate towards WCF is quite noticeable, manually parsing SOAP messages isn't too high on my wish list either :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900