我需要一些帮助调用wsdl Web服务功能。 WSDL有一个名为“Bye”的函数,它等待String类型的1个参数。然后它返回一种字符串文本。 如何在VBA下进行调用
我可以用我发送的预编译XML来调用它,但它给了我一个XML作为回报。必须有一个更简单的方法。
Dim URL As String
URL = "httx://webpage:8080/something/services/ByeService"
Dim requestDoc As New MSXML2.DOMDocument60
Dim root
Set root = requestDoc.createNode(1, "Envelope", "http://schemas.xmlsoap.org/soap/envelope/")
requestDoc.appendChild root
Dim nodeBody
Set nodeBody = requestDoc.createNode(1, "Body", "http://schemas.xmlsoap.org/soap/envelope/")
root.appendChild nodeBody
'Dim nodeOp
Set nodeOp = requestDoc.createNode(1, "Bye", "urn:MatrixService")
nodeBody.appendChild nodeOp
Dim nodeRequest
Set nodeRequest = requestDoc.createNode(1, "Bye", "urn:MatrixService")
'content of the request will vary depending on the WCF Service.'
' This one takes just a string. '
nodeRequest.Text = "This is a string to say goodbye"
nodeOp.appendChild nodeRequest
Set nodeRequest = Nothing
Set nodeOp = Nothing
Set nodeBody = Nothing
Set root = Nothing
'在这里,我可以使用XML调用它并获取XML Dim XMLHTTP作为新的MSXML2.XMLHTTP XMLHTTP.Open“POST”,“httx:// webpage:8080 / something / services / ByeService”,False XMLHTTP.setRequestHeader“Content-Type”,“text / xml” XMLHTTP.setRequestHeader“SOAPAction”,“urn:MatrixService” XMLHTTP.send requestDoc MsgBox XMLHTTP.responseText
答案 0 :(得分:0)
Set objXML = CreateObject("MSXML2.XMLHTTP")
strURL = "httx://webpage:8080/something/services/ByeService"
objXML.Open "POST", strURL, False
objXML.setRequestHeader "content-type", "text/xml"
objXML.setRequestHeader "SOAPAction", "urn:MatrixService"
objXML.Send "Bye"
strResult = objXML.ResponseText