Home > Mobile >  How to send request to a method of Web Service from Postman?
How to send request to a method of Web Service from Postman?

Time:12-08

I have an ASMX service, which has the below method. I want to debug this method, so I have put a breakpoint on it. But I am not able to send a request to it successfully, It gives a 404 error.

[WebMethod]
public void RequestNotification()
{

I have tried these options so far.

enter image description here

Page screenshots for reference.

enter image description here enter image description here

This is how I am calling from the C# code, and this is also not hitting the breakpoint on the method RequestNotification of service. and it's not giving any exceptions also in the C# code.

MyService myService= new MyService ();
myService.RequestNotification();

Update: I have tried as described in the below answer, I am still getting 404.

Please find below the request screenshot.

enter image description here

enter image description here

CodePudding user response:

Using POST call from Postman with XML Body

Demo code. I will show this enter image description here

enter image description here

POST URL

http://www.dneonline.com/calculator.asmx

In body with XML ray selection

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <Add xmlns="http://tempuri.org/">
      <intA>100</intA>
      <intB>200</intB>
    </Add>
  </soap:Body>
</soap:Envelope>

enter image description here

enter image description here

I got response this from service

<?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">
    <soap:Body>
        <AddResponse xmlns="http://tempuri.org/">
            <AddResult>300</AddResult>
        </AddResponse>
    </soap:Body>
</soap:Envelope>

If you click code button from Postman, you can get the curl command too.

curl --location --request POST 'http://www.dneonline.com/calculator.asmx' \
--header 'Content-Type: text/xml; charset=utf-8' \
--header 'SOAPAction: http://tempuri.org/Add' \
--data-raw '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <Add xmlns="http://tempuri.org/">
      <intA>100</intA>
      <intB>200</intB>
    </Add>
  </soap:Body>
</soap:Envelope>
'

enter image description here

CodePudding user response:

@Bench Vue's answer has helped me in solving the issue. I am able to solve the issue with the below request.

Request and Response:

enter image description here

enter image description here

  • Related