Link to home
Create AccountLog in
Avatar of Howard Katz
Howard KatzFlag for United States of America

asked on

How to post an soap xml file to a webservice and get the reponse

Hello Experts,

I am going a bit mad and I need your help.  My environment is Visual Studio 2010,, c#.

I am building a Soap Envelope and then I need to post it to a remote web service and get the response.

The web service is

and the response object goes to this method.


Here is what I have.  I build the xmlString.                  

DateTime thisMoment = DateTime.UtcNow;
 HttpWebRequest request = HttpWebRequest.Create("") as HttpWebRequest;

                request.Method = "POST";
                request.ContentType = "application/x-www-form-urlencoded";

                Encoding e = Encoding.GetEncoding("iso-8859-1");

                string xmlString = "<?xml version='1.0' encoding='utf-8'?>";
                xmlString += "<soap:Envelope xmlns:xsi='' ";
                xmlString += "xmlns:xsd='' ";
                xmlString += "xmlns:soap=''>";
                xmlString += "<soap:Header>";
                xmlString += "<wsse:Security soap:mustUnderstand='1' xmlns:wsse=''>";
                xmlString += "<wsse:UsernameToken>";
                xmlString += "<wsse:Username>HK1299</wsse:Username>";
                xmlString += "<wsse:Password Type='type info'>HK#$19s</wsse:Password>";
                xmlString += "<wsse:Nonce>124857285714</wsse:Nonce>";
                xmlString += "<wsu:Created xmlns:wsu=''>" + thisMoment + "</wsu:Created>";
                xmlString += "</wsse:UsernameToken>";
                xmlString += "</wsse:Security>";
                xmlString += "</soap:Header>";
                xmlString += "<soap:Body>";
                xmlString += "<EmpGetCitizenshipStatusCodes xmlns='' />";
                xmlString += "</soap:Body>";
                xmlString += "</soap:Envelope>";

                XmlDocument doc = new XmlDocument();
                XmlNamespaceManager objNM = null;

                objNM = new XmlNamespaceManager(doc.NameTable);
                objNM.AddNamespace("wsse", "");
                objNM.AddNamespace("wsu", "");

                string rawXml = doc.OuterXml;

After this, I have no idea what is happening.  How do I post what I just created and get the response.

Thank you so much if you can help


                System.Xml.XmlDocument SendingXmlDoc = new System.Xml.XmlDocument();

                System.Xml.XmlDocument response = new System.Xml.XmlDocument();
                string responseMsg = response.ToString();

                string requestText = string.Format("myxmldata={0}", HttpUtility.UrlEncode(rawXml, e));
                Stream requestStream = request.GetRequestStream();
                StreamWriter requestWriter = new StreamWriter(requestStream, e);

Here is what I have so far.  
Avatar of Manoj Patil
Manoj Patil
Flag of India image

Avatar of Howard Katz


I have tried dozens of ways but still no success.   I need to find someone who has worked with the federal government E-Verify Web Service.  Here is the URL to it.

If you have successfully made a request and gotten a response, please help !!!

Avatar of Howard Katz
Howard Katz
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
I need more time to check this. Currently little bit busy.
I paid a Software Engineer ($249) help with using WCF to communicate with this Web Service after searching for 2 weeks unsucessfully
Stuff like this with no solution shouldn't be in the "must reads." Wasted my time. :(