I have a WCF service reference:
http://.../Service.svc(?WSDL)
and I have an XML file containing a compliant SOAP envelope
You could try using the webclient class and posting your xml to the service.
I just want to comment that Darin's response worked for me, except that I had to take out the extra quotes around the SOAPAction header value (substitute your uri, of course):
client.Headers.Add("SOAPAction", "http://www.example.com/services/ISomeOperationContract/GetContract");
You could use UploadString. You need to set the Content-Type
and SOAPAction
headers appropriately:
class Program
{
static void Main(string[] args)
{
using (var client = new WebClient())
{
// read the raw SOAP request message from a file
var data = File.ReadAllText("request.xml");
// 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", "\"http://www.example.com/services/ISomeOperationContract/GetContract\"");
var response = client.UploadString("http://example.com/service.svc", data);
Console.WriteLine(response);
}
}
}