Link to home
Start Free TrialLog in
Avatar of zorba111

asked on

My first SOAP client. I have constructed the XML message... how to send?

I'm using C# to write something to make it easier to post my company's jobs.

One of the job boards allows us to upload jobs using a webservice, and we have to send it a SOAP envelope.

(see section "Create the XML Request" on page )

I have constructed my XML as a System.String based on user input in a form. I based it on the XML example given by the webservice provider.

I haven't used SOAP before so I thought I could just POST the XML to the URL using HttpWebRequest, as I did this with another more basic webservice (see earlier post: However I got a 400 error.

So I googled sending a SOAP message and I got this:
But it doesn't allow (or so it seems to me) to just append the *already formed* XML message and simply send it (or am I wrong).

(on top of that the SOAPClient class is in microsoft.web.services3.dll which aint on my machine)

So maybe looking for another way...

Any tips guys?
Avatar of zorba111


My latest attempt:

            String sResponse;
            // from:
            using (var client = new WebClient())
                // the Content-Type needs to be set to XML
                client.Headers.Add("Content-Type", "text/xml;charset=utf-8");
                // The SOAPAction header indicates which method you would like to invoke
                // and could be seen in the WSDL: <soap:operation soapAction="..." /> element
                client.Headers.Add("SOAPAction", "");
                    // 2nd param in example was "\"\"");
                // but..
                sResponse = client.UploadString("", 

Open in new window

I get an exception on the WebClient.UploadString() call
exception message is "400: bad request"
Avatar of Mark Bullock
Mark Bullock
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm using VS2008 and therefore .net 3.5
I think you can try that download link I included.
If you need them, here are detailed instructions for installing it.
Thanks Mark!

When I got stuck with doing it the "raw" way, I switched over to trying to do it using WCF. I'm making progress with that method, but too early to say for sure.

In any case I'm gonna come back to this and try your suggestions, after I've exhausted the WCF route - either to success or to deadlock lol.
Why don't you just create a web service reference?

Steps to generate proxy interface to work with .net framework versions 2.0 and greater

Run (prefered):
Or (from Visual Studio)
User generated imageAnd then use it like so:
MonsterBusinessGatewayService.Job job = new MonsterBusinessGatewayService.Job();
job.jobAction = MonsterBusinessGatewayService.JobJobAction.add;

MonsterBusinessGatewayService.BusinessGatewayInterfaceClient gateway = new MonsterBusinessGatewayService.BusinessGatewayInterfaceClient();
gateway.UpdateJob(/*parameters here*/, job);

Open in new window

Just spotted your other question on the matter. The code snippet I posted there might help get you on the right track. If you look at the SOAP sample, you will what objects you need to construct and pass into the UpdateJob call, and what values you need to set.