服务器为什么读不到参数
用C++写的一个客户端(SOAP Toolkit 3.0),向服务器发送了数据(用抓包工具抓到的):
<?xml version= "1.0 " encoding= "UTF-8 " standalone= "no " ?>
- <soap:Envelope xmlns:SOAPSDK1= "http://www.w3.org/2001/XMLSchema " xmlns:SOAPSDK2= "http://www.w3.org/2001/XMLSchema-instance " xmlns:SOAPSDK3= "http://schemas.xmlsoap.org/soap/encoding/ " xmlns:soap= "http://schemas.xmlsoap.org/soap/envelope/ ">
- <soap:Body>
- <SOAPSDK4:AddOrder xmlns:SOAPSDK4= "http://tempuri.org/ ">
<strName> SunWZ </strName>
</SOAPSDK4:AddOrder>
</soap:Body>
</soap:Envelope>
但服务器无法读到参数strName
服务器代码(.net 2003 C#):
[WebMethod]
public string AddOrder(string strXml)
{
if(strXml != " ")
return "ok ";
else
return "false ";
}
从网页上测试副服务器是正确的.
[解决办法]
你的服务器抓到了那段xml了吗?
AddOrder返回了false?
[解决办法]
VB通过SOAP调用WebService
Dim soapclient
Const WSDL_URL = "http://localhost/Interface/Interface.asmx?WSDL "
set soapclient = Server.CreateObject( "MSSOAP.SoapClient30 ")
soapclient.ClientProperty( "ServerHTTPRequest ") = True
soapclient.mssoapinit WSDL_URL
soapclient.AddOrder "SunWZ "
[解决办法]
随便段下吧
[解决办法]
你用SOAP Toolkit做的就是一个发送soap请求的程序(客户端)吧?
我觉得问题处在你的服务端,
不知道你怎么能确定服务端程序没读到参数(服务端的程序比较难调试)?
我认为你的方法既然有返回值就是要返回给客户端的吧?
所以应该在方法前声明返回值的情况。
给你个例子:
[WebMethod]
// 用来做用户验证的
[System.Web.Services.Protocols.SoapHeaderAttribute( "AuthenticationInfo ")]
[return: System.Xml.Serialization.XmlElementAttribute( "Request_ID ")]
public String CreateASR( ....).....