C# 如何使用SOAPUI访问Web服务的不同方法
我试图用soapui访问我的webmethods,但它只对第一个有效,我不明白为什么 我的Web服务方法:C# 如何使用SOAPUI访问Web服务的不同方法,c#,asp.net,soapui,C#,Asp.net,Soapui,我试图用soapui访问我的webmethods,但它只对第一个有效,我不明白为什么 我的Web服务方法: [SoapHeader ("AuthenticationInfo", Required=true)] [WebMethod(EnableSession = true)] public string HelloWorld() { if (!(AuthenticationInfo.Username == "test" && Authen
[SoapHeader ("AuthenticationInfo", Required=true)]
[WebMethod(EnableSession = true)]
public string HelloWorld()
{
if (!(AuthenticationInfo.Username == "test" && AuthenticationInfo.Password == "test"))
{
throw new Exception();
// I put that in the aim to get an error, I'll modify this later
}
return "OK";
}
[SoapHeader("AuthenticationInfo", Required = true)]
[WebMethod]
public string Authenticate(string MethodName)
{
if (!(AuthenticationInfo.Username == "test" && AuthenticationInfo.Password == "test")
{
throw new Exception();
}
else
{
HelloWorld();
}
return "aaaa";
}
[WebMethod]
public int Calcul(int a, int b)
{
return a+b ;
}
当我将此XML放入SOAP UI时:
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<AuthHeader xmlns="http://tempuri.org/">
<Username>test</Username>
<Password>test</Password>
<key>string</key>
</AuthHeader>
</soap:Header>
<soap:Body>
<HelloWorld xmlns="http://tempuri.org/" />
</soap:Body>
</soap:Envelope
,因此我使用URL“”处的最后一个XML尝试新请求,但出现错误
你知道吗?我可能用错了SOAP用户界面吗
答复科萨拉W:
我得到了一个这样的UI,在那里我可以点击方法。calcul方法只在这里工作,因为这个方法不需要SoapHeader
以下是答案:
当您在SOAP UI中指定URL时,您需要在末尾添加?wsdl,如下所示:http://localhost:62353/MyWebService.asmx?wsdl
然后我在SOAP UI中刷新项目,所有方法都会出现当您在浏览器中运行web服务项目时,您可以看到哪些方法?您可以单击它们并查看模式吗?@Kosala当我运行web服务项目时,我在屏幕上放置了一个图像
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Calcul xmlns="http://tempuri.org/">
<a>1</a>
<b>1</b>
</Calcul>
</soap:Body>
</soap:Envelope>