Niranjan Godbole
Niranjan Godbole

Reputation: 2175

How to test wcf soap service using POSTMAN?

Hi I am developing XML Soap services using WCF. My requirement is to update some database table. I have one method to update values in the db. Below is my service.

  [ServiceContract]
public interface IOpportunity
{
    [OperationContract]
    [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Xml, UriTemplate = "postmethod/updateOpportunity")]
    bool updateOpportunity(opportunityActivity obj);
}
[DataContract]
public class opportunityActivity
{
    [DataMember]
    public string opportunityID { get; set; }
    [DataMember]
    public string opportunityStatus { get; set; }
    [DataMember]
    public string opportunityserviceType { get; set; }
}

Missing method

Below is my xml.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s="http://localhost:39512/Opportunity.svc">
   <soapenv:Header/>
   <soapenv:Body>
      <s:request>
       <opportunityID>1-1D5SJX</opportunityID>
       <opportunityStatus>Completed</opportunityStatus>
       <opportunityserviceType>LEASE_REQUEST</opportunityserviceType>
      </s:request>
   </soapenv:Body>
</soapenv:Envelope>

when i i try as shown above i get 400 bad request error.May i know am i following correct approach to test the service? Can someone correct me if i am doing wrong? Any help would be greatly appreciated. Thank you.

Upvotes: 3

Views: 22983

Answers (1)

tom redfern
tom redfern

Reputation: 31780

You have to pass a soap message to the service endpoint.

Eg

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s="http://myNamespace/">
   <soapenv:Header/>
   <soapenv:Body>
      <s:request>
          ....
      </s:request>
   </soapenv:Body>
</soapenv:Envelope>

To get hold of a soap message you should use the service endpoint definition and use some tooling to generate a valid request.

Additionally, you should not be sending data to the endpoint address with ?wsdl as part of the address. It should only be the endpoint address.

Upvotes: 2

Related Questions