我得到了需要调用的 Web 服务的这种结构。ws 名称是 Set_Details 我做对了,所以不会导致错误。我无法弄清楚如何解决这个问题。当我调用它时,我得到了错误:
System.InvalidOperationException:Set_Details Web 服务方法名称无效。在 System.Web.Services.Protocols.HttpServerProtocol.Initialize() 在 System.Web.Services.Protocols.ServerProtocol.SetContext(类型类型,HttpContext 上下文,HttpRequest 请求,HttpResponse 响应)在 System.Web.Services.Protocols.ServerProtocolFactory。创建(类型类型、HttpContext 上下文、HttpRequest 请求、HttpResponse 响应、Boolean& abortProcessing)
*我将真实网址路径更改为假地址,因此请忽略网址
<?xml version="1.0" encoding="utf-8"?>
<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>
<Set_Details xmlns="http://ws.blobobobo.uk/WebService/">
<Details>
<Number>int</Number>
<Category>string</Category>
</Details>
<LoginID>string</LoginID>
<LoginPassword>string</LoginPassword>
</Set_Details>
</soap:Body>
</soap:Envelope>
这是我调用类网络服务的代码
dim ws
set ws = new webservice
ws.url = mainip
ws.method = "Set_OrderDetails"
ws.parameters.Add "Number", "6166""
ws.parameters.Add "Category", "ffff"
ws.parameters.Add "LoginID", "ex10"
ws.parameters.Add "LoginPassword", "ex20"
ws.execute
response.write ws.response
set ws = nothing
这是代表网络服务的我的班级
class WebService
public Url
public Method
public Response
public Parameters
public function execute()
dim xmlhttp
Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
xmlhttp.open "POST", Url & "/" & Method, false
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.send Parameters.toString
response = xmlhttp.responseText
set xmlhttp = nothing
end function
Private Sub Class_Initialize()
Set Parameters = new wsParameters
End Sub
Private Sub Class_Terminate()
Set Parameters = Nothing
End Sub
end class
class wsParameters
public mCol
public function toString()
dim nItem
dim buffer
buffer = ""
for nItem = 1 to Count
buffer = buffer & Item(nItem).toString & "&"
next
if right(buffer,1)="&" then
buffer = left(buffer,len(buffer)-1)
end if
toString = buffer
end function
public sub Clear
set mcol = nothing
Set mCol = CreateObject("Scripting.Dictionary")
end sub
public sub Add(pKey,pValue)
dim newParameter
set newParameter = new wsParameter
newParameter.Key = pKey
newParameter.Value = pValue
mCol.Add mCol.count+1, newParameter
set newParameter = nothing
end sub
public function Item(nKey)
set Item=mCol.Item(nKey)
end function
public function ExistsXKey(pKey)
dim nItem
for nItem = 1 to mcol.count
if mCol.Item(nItem).key = pKey then
ExistsXKeyword = true
exit for
end if
next
end function
public sub Remove(nKey)
mCol.Remove(nKey)
end sub
public function Count()
Count=mCol.count
end function
Private Sub Class_Initialize()
Set mCol = CreateObject("Scripting.Dictionary")
End Sub
Private Sub Class_Terminate()
Set mCol = Nothing
End Sub
end class
class wsParameter
public Key
public Value
public function toString()
toString = Key & "=" & Value
end function
end class
Dim ip
mainip="http://ws.bloblobo.uk/WebServices/ws.asmx"