Hi,
I have the following SOAP message that i want to post it to my WCF Service and get response.
"<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\">\r\n <s:Header>\r\n <a:Action s:mustUnderstand=\"1\">http://schemas.devleap.com/OrderService/IOrderService/InsertOrder</a:Action>\r\n <a:MessageID>urn:uuid:4cb619b7-365b-4108-880f-b302029d03c2</a:MessageID>\r\n <a:ReplyTo>\r\n <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>\r\n </a:ReplyTo>\r\n </s:Header>\r\n <s:Body>\r\n <InsertOrder xmlns=\"http://schemas.devleap.com/OrderService\">\r\n <order xmlns:d4p1=\"http://schemas.devleap.com/OrderService/Order\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n <d4p1:IdCustomer>2</d4p1:IdCustomer>\r\n <d4p1:IdOrder>46</d4p1:IdOrder>\r\n <d4p1:OrderItems xmlns:d5p1=\"http://schemas.devleap.com/OrderService/OrderItems\" xmlns:d5p2=\"http://schemas.devleap.com/OrderService/OrderItem\">\r\n <d5p1:OrderItem>\r\n <d5p2:IdProduct>P01</d5p2:IdProduct>\r\n <d5p2:Quantity>5</d5p2:Quantity>\r\n <d5p2:EuroPrice>20</d5p2:EuroPrice>\r\n </d5p1:OrderItem>\r\n <d5p1:OrderItem>\r\n <d5p2:IdProduct>P01</d5p2:IdProduct>\r\n <d5p2:Quantity>5</d5p2:Quantity>\r\n <d5p2:EuroPrice>20</d5p2:EuroPrice>\r\n </d5p1:OrderItem>\r\n </d4p1:OrderItems>\r\n </order>\r\n </InsertOrder>\r\n </s:Body>\r\n</s:Envelope>"
How can i post this SOAP to the WCF service? I tried this but i get "The remote server returned an error: (500) Internal Server Error." exception.
using (var client = new WebClient())
{
client.Headers.Add("Content-Type", "application/soap+xml; charset=utf-8");
var response = client.UploadString("http://localhost:8000/OrderService", data);
}
If i remove the header from Envelope and add:
client.Headers.Add("Content-Type", "application/soap+xml; charset=utf-8");
client.Headers.Add("SOAPAction", "\"http://schemas.devleap.com/OrderService/IOrderService/InsertOrder\"");
i get the same error.
If i put
client.Headers.Add("Content-Type", "text/xml; charset=utf-8");
i get exception that server expects "application/soap+xml; charset=utf-8".
If someone knows how to call it right please help.
Thank you, Adrya