I need to send a SOAP request to a URL. But i find this harder then i thought it would be.
The request that i have to send is:
string bla = "" +
"<?xml version='\"1.0\" encoding=\"UTF-8\"?>" +
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
"<soap:Body>" +
"<ns1:sendNotificationResponse" +
"xmlns=\"http://notification.services.adyen.com\"" +
"xmlns:ns2=\"http://common.services.adyen.com\">" +
"<notificationResponse>[accepted]</notificationResponse>" +
"</sendNotificationResponse>" +
"</soap:Body>" +
"</soap:Envelope>";
I've been given an URL: https://ca-test.adyen.com/ca/services/Notification?wsdl
The problem is, is that I'm not sure how to go on from here. Can i simply just send a request to that URL? Or do I have to import the WSDL somehow first?
I've found a lot of examples on the net, but I couldn't really make sense out of most of them. Some were even out dated, because they were still using: Microsoft.Web.Services3
So in short, I'm kinda clueless on what I exactly have to do here and how. I simply want to send that 'SOAP' message...
If you want to inspect more SOAP request examples, head to the Public SOAP APIs collection. In the Body tab, select raw and choose XML from the dropdown list. Enter your XML in the text entry area. Your request body must include the SOAP Envelope, Header, and Body tags as required by the endpoint, as well as any namespaces.
To test a SOAP web service, we just need to make HTTP requests with a SOAP envelope in the request body. For our web service, a simple HTTP POST request is:
Content-Type. The Content-Type header for a SOAP request and response defines the MIME type for the message and the character encoding (optional) used for the XML body of the request or response.
Syntax Rules. Here are some important syntax rules: A SOAP message MUST be encoded using XML. A SOAP message MUST use the SOAP Envelope namespace. A SOAP message MUST use the SOAP Encoding namespace. A SOAP message must NOT contain a DTD reference. A SOAP message must NOT contain XML Processing Instructions.
You can do this by adding a service reference to the endpoint URL you've provided in the question. Then you can call the web method as you would call a normal method, just off the client object. Step-by-step below:
ServiceReference1.NotificationPortTypeClient client = new ServiceReference1.NotificationPortTypeClient(); client.sendNotification(...);
Edit
Looking at the web service in more detail, it looks as though the SOAP request you have included in the question is the response that would be sent back by the url when you had invoked the method - not the request you would send to the web service to invoke the method.
Wouldn't it be easier to add a web service reference in Visual Studio? What you get are "stub" classes that allow you to communicate with the web service using normal classes and methods - you don't need to care about the SOAP messages being sent or whatnot.
To add such a reference, you can select the "Add Service Reference" context menu item. Depending on the type of service, you will need to press the button in the lower left of the service reference dialog (in German this is called "Erweitert", which would translate to "Enhanced" or "Extended"). The next dialog also has a button at the lower left in the "Compatibility" section to add a ".NET 2.0 style web service reference".
One of the two should help you.
If you need to send the request manually, you would send a POST request to the web service's URL adding the XML code as the requests body.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With