Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
While trying to post xml,. I can't get the xml request. I am testing my web method in fiddler tool. what i miss here?

**C# Class & WebMethod -**

public struct Employee
            {
                public string Name;
                public int Age;
                public float Salary;
            }

        [WebMethod]
        public Employee HelloWorld(Employee emp)
        {
            emp.Name = "Mr " + emp.Name;
            emp.Age += 1;
            emp.Salary += 5000.0f;
            return emp;
        }


**XML Request -**

<?xml version="1.0" encoding="utf8" ?>
  <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <soap:Body>
          <HelloWorld xmlns="http://www.silan.com.au/test">
              <emp>
                         <Name>Bob</Name>
                         <Age>20</Age>
                         <Salary>60000</Salary>
                   </emp>
             </HelloWorld>
        </soap:Body>
  </soap:Envelope>


**Result in Raw Format -**

POST http://localhost:49633/xmlRequest.aspx/HelloWorld HTTP/1.1
    User-Agent: Fiddler
    Host: localhost:49633
    Content-Type: text/xml
    Content-Length: 521
    
       <?xml version="1.0" encoding="utf8" ?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <soap:Body>
            <HelloWorld xmlns="http://www.silan.com.au/test">
                <emp>
                           <Name>Bob</Name>
                           <Age>20</Age>
                           <Salary>60000</Salary>
                     </emp>
               </HelloWorld>
          </soap:Body>
    </soap:Envelope>
Posted

1 solution

you have marked aspx page method as webmethod but if you need to call this method as web service you need to create asmx web service, wcf web service or other web service API which enable you to call the method as web service.
for testing purpose add web service file to your asp.net project (.asmx file) and include your method, set that page as startup page and run the application. then you can see the service operations and how those service operation soap request created.
check below detailed process of testing web service using fiddle
Tutorial: Using Fiddler to Compose HTTP SOAP Requests to the AppFxWebService.asmx[^]
But fiddle is not web service testing tool which I recommend, try soapUI
Test Your ASP.NET WebService using SoapUI[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900