使用SOAP从VBA调用Webservice

我正在尝试在Excelmacros中调用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 

我回来了以下回应:

  <?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> 

以前有人做过这样的事情吗?

您的SOAP操作还应该包含方法的命名空间

 "http://tempri.org/PutSchedule" 

找出您的服务的名称空间,并将其添加到方法名称PutSchedule的前面。

看起来更像是使用xml-rpc而不是soap。 使用肥皂types库与webservice进行交互: http : //msdn.microsoft.com/en-us/library/aa192537(office.11​​).aspx ,或与您的ms office版本相对应的那个