使用 SOAP 从 VBA 调用 Web 服务
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/241725/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Calling a Webservice from VBA using SOAP
提问by Kevin Colyar
I'm trying to call a web service in an Excel Macro:
我正在尝试在 Excel 宏中调用 Web 服务:
Set objHTTP = New MSXML.XMLHTTPRequest
objHTTP.Open "post", "https://www.server.com/EIDEServer/EIDEService.asmx"
objHTTP.setRequestHeader "Content-Type", "text/xml"
objHTTP.setRequestHeader "SOAPAction", "PutSchedule"
objHTTP.send strXML
And I get back the following response:
我得到以下回复:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Server did not recognize the value of HTTP Header SOAPAction: PutSchedule.</faultstring>
<detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>
Anybody out there done something like this before?
以前有人做过这样的事情吗?
采纳答案by Ray Lu
You SOAP action should also include namespace of the method e.g.
您的 SOAP 操作还应包括方法的名称空间,例如
"http://tempri.org/PutSchedule"
Find out what the namespace of your Service and add it in front of the method name PutSchedule.
找出你的 Service 的命名空间并将其添加到方法名称 PutSchedule 的前面。
回答by Ray Lu
looks more like you're using xml-rpc instead of soap. interact with the webservice using the soap type library at : http://msdn.microsoft.com/en-us/library/aa192537(office.11).aspx, or the one that corresponds with your ms office version
看起来更像是您使用的是 xml-rpc 而不是soap。使用soap 类型库与webservice 交互:http: //msdn.microsoft.com/en-us/library/aa192537(office.11).aspx,或与您的ms office 版本相对应的那个

