2016-07-14 6 views
0

Excel 2010のVBAでSOAPリクエストを使用して情報を取得しようとしていますが、以前はこれを使用していませんでしたが、何かがうまくいくはずだが、私は同じエラー(SOAPActionヘッダなし)に悩まされ続けている。私はSoapUIでWSDLを試してみましたが、どこに間違っているのか分かりません。Excel 2010のVBAでSOAPActionヘッダーエラーが発生しない

私は要求を行っていますWSDL:

http://www.banxico.org.mx/DgieWSWeb/DgieWS?WSDL 

エラー私は得続ける:

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
<soapenv:Body> 
    <soapenv:Fault> 
    <faultcode xmlns:ns1="http://xml.apache.org/axis/">ns1:Client.NoSOAPAction</faultcode> 
    <faultstring>no SOAPAction header!</faultstring> 
    <detail> 
    <ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">SERVAP9</ns2:hostname> 
    </detail> 
    </soapenv:Fault> 
</soapenv:Body> 
</soapenv:Envelope> 

私が使用していますVBAコード:

Option Explicit 
Sub SOAP() 
'Set and instantiate our working objects 
    Dim Req As Object 
    Dim sEnv As String 
    Dim Resp As New MSXML2.DOMDocument60 
    Set Req = CreateObject("MSXML2.XMLHTTP") 
    Set Resp = CreateObject("MSXML2.DOMDocument.6.0") 
    Req.Open "Post", "http://www.banxico.org.mx/DgieWSWeb/DgieWS?WSDL", False 


'Create SOAP envelope for submission to the Web Service 
    sEnv = sEnv & "<soapenv:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:ws=""http://ws.dgie.banxico.org.mx"">" 
    sEnv = sEnv & " <soapenv:Header/>" 
    sEnv = sEnv & " <soapenv:Body>" 
    sEnv = sEnv & " <ws:tiposDeCambioBanxico soapenv:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/""/>" 
    sEnv = sEnv & " </soapenv:Body>" 
    sEnv = sEnv & "</soapenv:Envelope>" 

' Send SOAP Request 
    Req.send (sEnv) 

' Display results in MessageBox 
    'MsgBox Req.responseText 

    Resp.LoadXML Req.responseText 
    Debug.Print Req.responseText 

    'clean up code 
    Set Req = Nothing 
    Set Resp = Nothing 
End Sub 

答えて

0

このブロックで:

'Create SOAP envelope for submission to the Web Service 
    sEnv = sEnv & "<soapenv:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:ws=""http://ws.dgie.banxico.org.mx"">" 
    sEnv = sEnv & " <soapenv:Header/>" 
    sEnv = sEnv & " <soapenv:Body>" 
    sEnv = sEnv & " <ws:tiposDeCambioBanxico soapenv:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/""/>" 
    sEnv = sEnv & " </soapenv:Body>" 
    sEnv = sEnv & "</soapenv:Envelope>" 

<soapenv:Header/>を削除するか、対応する</soapenv:header></soapenv:Body>の後に追加する必要があります。

+0

両方の提案を試しても同じエラーが表示されます。 – Chance

関連する問題