使用SOAP从VBA调用Web服务

Kev*_*yar 7 excel vba web-services excel-vba

我正在尝试在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      
Run Code Online (Sandbox Code Playgroud)

我得到以下回复:

  <?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> 
Run Code Online (Sandbox Code Playgroud)

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

Ray*_* Lu 4

您的 SOAP 操作还应该包括方法的名称空间,例如

"http://tempri.org/PutSchedule"
Run Code Online (Sandbox Code Playgroud)

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

  • 您能说得更具体一点吗?我知道这条消息已经有 3 年多了,但这就是拥有这样的论坛的意义,对吗? (2认同)