在提琴手发布时不会触发webmethod [英] webmethod not trigger while post in fiddler

查看:71
本文介绍了在提琴手发布时不会触发webmethod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试发布xml时。我无法获得xml请求。我在fiddler工具中测试我的web方法。我想念的是什么?



** C#Class& WebMethod - **



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请求 - **





**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>

推荐答案

您已将aspx页面方法标记为webmethod但是如果需要调用此方法作为Web服务的方法,您需要创建asmx Web服务,wcf Web服务或其他Web服务API,使您可以将该方法作为Web服务调用。

用于测试目的将web服务文件添加到您的asp.net项目(.asmx文件)并包含您的方法,将该页面设置为启动页面并运行该应用程序。然后您可以看到服务操作以及如何创建这些服务操作soap请求。

查看下面使用小提琴测试网络服务的详细过程

教程:使用Fiddler将HTTP SOAP请求编写到AppFxWebService.asmx [ ^ ]

但是小提琴不是我推荐的网络服务测试工具,试试soapUI

使用SoapUI测试ASP.NET WebService [ ^ ]
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[^]


这篇关于在提琴手发布时不会触发webmethod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆