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 http://partner.monster.com/real-time-posting-devguide )

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: http://www.experts-exchange.com/questions/28708426/use-C-to-attach-to-a-URL-and-get-an-XML-feed.html). However I got a 400 error.

So I googled sending a SOAP message and I got this:
https://msdn.microsoft.com/en-us/library/aa529276.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-3
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?
thanks
zorba111Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zorba111Author Commented:
My latest attempt:

            String sResponse;
            // from: http://stackoverflow.com/questions/1728293/sending-raw-soap-xml-directly-to-wcf-service-from-c-sharp
            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 "\"http://www.example.com/services/ISomeOperationContract/GetContract\"");
                // but.. http://archive.oreilly.com/pub/post/unraveling_the_mystery_of_soap.html
                sResponse = client.UploadString("https://gateway.monster.com:8443/bgwBroker", 
                                                    sSOAPmessage);
                //Console.WriteLine(response);
            }

Open in new window


I get an exception on the WebClient.UploadString() call
exception message is "400: bad request"
0
Mark BullockQA Engineer IIICommented:
If you have Visual Studio 2005 and .NET Framework 2.0 you can download and install Web Services Enhancements which includes the DLL you mentioned.
http://www.microsoft.com/en-us/download/details.aspx?id=14089
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zorba111Author Commented:
I'm using VS2008 and therefore .net 3.5
0
How do you know if your security is working?

Protecting your business doesn’t have to mean sifting through endless alerts and notifications. With WatchGuard Total Security Suite, you can feel confident that your business is secure, meaning you can get back to the things that have been sitting on your to-do list.

Mark BullockQA Engineer IIICommented:
I think you can try that download link I included.
If you need them, here are detailed instructions for installing it.
http://digantakumar.com/2010/06/04/wse-3-in-visual-studio-2008-and-2010/
0
zorba111Author Commented:
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.
0
MlandaTCommented:
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):
SvcUtil.exe https://gateway.monster.com:8443/bgwBroker
Or:
wsdl.exe https://gateway.monster.com:8443/bgwBroker
Or (from Visual Studio)
Add Service Reference in Visual StudioAnd 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

0
MlandaTCommented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Services

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.