2016-07-14 10 views
0

Ich versuche, einige Informationen über eine SOAP-Anfrage in VBA in Excel 2010 zu erhalten. Ich habe das nicht zuvor verwendet, aber ich habe einige suchen und angepasst verschiedene Codes zu kommen mit etwas, das ich denke, sollte funktionieren, aber ich bleibe mit dem gleichen Fehler stecken (keine SOAPAction-Header). Ich habe versucht, die WSDL in SoapUI und es funktioniert, so bin ich mir nicht sicher, wo ich falsch liege.Kein SOAPAction-Header Fehler mit VBA in Excel 2010

Die WSDL ich, damit ich bin die Anfrage an:

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

Der Fehler Ich erhalte:

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

Der VBA-Code Ich verwende:

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 

Antwort

0

In diesem Block :

'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>" 

Sie sollten die <soapenv:Header/> herausnehmen oder eine entsprechende </soapenv:header> nach der Zeile </soapenv:Body> hinzufügen.

+0

Ich bekomme immer noch den gleichen Fehler nach dem Versuch, beide Vorschläge. – Chance