tags:

views:

780

answers:

4

Hi

I want to call a WCF service using SOAP?

this is my contract:

[ServiceContract(Namespace = "http://www.MySite.com/Services/TransferFile")]
public interface ITransferFile : ICloseableAndAbortable
{
    /// <summary>
    /// This will send the file which is associated with this rule to all the subscribers.
    /// </summary>
    /// <param name="ruleId"></param>
    [OperationContract]
    void ByRuleId(int ruleId);
}

the binding is currently set to this, will i need to change it?

<endpoint address="" binding="wsHttpBinding" contract="FileTransfer.Wcf.ITransferFile">

so how would i call it via soap? for example using the (HttpWebRequest)WebRequest

Many thanks in advance

+1  A: 

Is there a reason you prefer WebRequest instead of generating a client proxy with svcutil.exe which takes care of all the plumbing?

Darin Dimitrov
I have a collegue whom is using Sharepoint designer, to create a workflow that will call a webservice, snag is the 3rd party tool he is useing cannot do WCF it can only understand SOAP Action, and body.. thus im looking for a simple example which i can test in .net (the WebRequest) and then just pass him the string he requires
dbones
+3  A: 
  1. Change the Binding to basicHttpBinding

2 the message

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
  <soap:Body>
    <ByRuleId xmlns="http://www.MySite.com/Services/TransferFile"&gt;
      <ruleId>3</ruleId>
    </ByRuleId>
  </soap:Body>
</soap:Envelope>

3 the soap action

POST /FileTransferService/TransferFile.svc HTTP/1.1
SOAPAction: "http://www.MySite.com/Services/TransferFile/ITransferFile/ByRuleId"

fyi i asked for a (HttpWebRequest)WebRequest, only as a posible way, I ended up using a Web Reference and fiddler

dbones
+1  A: 

There's a number of ways you can do this:

  • create a little WCF client for your service yourself, by using svcutil or "Add Service Reference" in a Visual Studio project
  • run a SOAP testing tool like SoapUI or WCFStorm against your service and create requests and call your service (and see the results)
  • use the WCF test client WcfTestClient.exe which is in your (Visual Studio)\Common7\IDE\Tools\bin (?? not 100% sure about the location - check and you'll find it for sure!) and which allows you to connect to a running WCF service, inspect its operations, and also call them

Marc

marc_s
A: 

Hi dbones,

Can you please provide me sample code?

Its urgent.

Regards, Niranjan

Niranjan
this should be a comment on the answer. It's not an answer.
Kate Gregory