2016-05-23 16 views
0

erhalte ich einen Web-Service-Fehler beim Versuch, einen Webservice-Aufruf über VBA mit SOAP auszuführen. Die XML-Ausgabe und VBA-Code ist unten. Ich würde es schätzen, wenn irgendjemand beraten könnte, wenn es irgendeinen offensichtlichen Fehler im VBA-Code gibt.WebService Fehler einen Webservice von VBA aufrufen SOAP

XML

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"  xmlns:prag="http://www.pragmaticsw.com/"> 
<soap:Body> 
    <prag:Bugs_LoadByCriteria> 
    <prag:AuthenticationData> 
     <prag:AppCode>agSP</prag:AppCode> 
     <prag:DeptId>81842</prag:DeptId> 
     <prag:ProjId>92553</prag:ProjId> 
     <prag:UserId>147280</prag:UserId> 
     <prag:PassCode>Password1</prag:PassCode> 
    </prag:AuthenticationData> 
    <prag:Condition><![CDATA[<Conditions  xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' 
xmlns:xsd='http://www.w3.org/2001/XMLSchema' Operation='opLIKE'> 
<Items Type='tField'> 
    <Value xsi:type='xsd:string'>Custom17</Value> 
</Items> 
<Items Type='tString'> 
    <Value xsi:type='xsd:string'>SIT5</Value> 
</Items> 
</Conditions>]]></prag:Condition> 
    </prag:Bugs_LoadByCriteria> 
</soap:Body> 
</soap:Envelope> 

VBA:

Sub login() 

Dim responseText As String 
Dim sURL As String 
Dim sEnv As String 
Dim xmlhtp As New MSXML2.XMLHTTP 
Dim xmlDoc As New DOMDocument 
Dim webserviceSOAPActionNameSpace 

sURL = "http://soap.qacomplete.smartbear.com/psWS.asmx" 

sEnv = "<?xml version =""1.0"" encoding=""utf-8""?>" 
sEnv = sEnv & "<soap:Envelope xmlns:soap=""http://www.w3.org/2003/05/soap- envelope"" xmlns:prag=""http://www.pragmaticsw.com/"">" 
sEnv = sEnv & "<soap:Body>" 
sEnv = sEnv & "<prag:Bugs_LoadByCriteria>" 
sEnv = sEnv & "<prag:AuthenticationData>" 
sEnv = sEnv & "<prag:AppCode>agSP</prag:AppCode>" 
sEnv = sEnv & "<prag:DeptId>81842</prag:DeptId>" 
sEnv = sEnv & "<prag:ProjId>92553</prag:ProjId>" 
sEnv = sEnv & "<prag:UserId>147280</prag:UserId>" 
sEnv = sEnv & "<prag:PassCode>Password1</prag:PassCode>" 
sEnv = sEnv & "</prag:AuthenticationData>" 
sEnv = sEnv & "<prag:Condition><![CDATA[<Conditions  xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" 
sEnv = sEnv & "xmlns:xsd='http://www.w3.org/2001/XMLSchema' Operation='opLIKE'>" 
sEnv = sEnv & "<Items Type='tField'>" 
sEnv = sEnv & "<Value xsi:type='xsd:string'>Custom17</Value>" 
sEnv = sEnv & "</Items>" 
sEnv = sEnv & "<Items Type='tString'>" 
sEnv = sEnv & "<Value xsi:type='xsd:string'>SIT4</Value>" 
sEnv = sEnv & "</Items>" 
sEnv = sEnv & "</Conditions>]]></prag:Condition>" 
sEnv = sEnv & "</prag:Bugs_LoadByCriteria>" 
sEnv = sEnv & "</soap:Body>" 
sEnv = sEnv & "</soap:Envelope>" 

With xmlhtp 

webserviceSOAPActionNameSpace = "http://www.pragmaticsw.com/" 

    .Open "POST", sURL, False 

    .setRequestHeader "post", "http://soap.qacomplete.smartbear.com/psWS.asmx HTTP/1.1" 
    .setRequestHeader "Content-Type", "application/soap+xml; charset=UTF-8" 
    .setRequestHeader "SOAPAction", webserviceSOAPActionNameSpace & "Bugs_LoadByCriteria" 

    .send sEnv 
    xmlDoc.LoadXML .responseText 
    MsgBox .responseText 

End With 

End Sub

+0

Haben Sie Ihren Webservice mit einem Tool wie SoapUI getestet? Beginne dort –

+0

Danke David. Das XML wurde mithilfe der SOAP-Benutzeroberfläche erstellt und getestet. Jetzt versuche ich das XML in ein Format zu strukturieren, das VBA lesen kann (Verweis auf Microsoft XML 6.0) –

+0

Welchen Fehler bekommen Sie? –

Antwort

0

meine eigene Abfrage beantwortet. Ich habe den sEnv-Inhalt über SoapUI an den Web-Service gesendet und den gleichen internen Web-Service-Fehler erhalten. Überprüfen Sie das resultierende XML-Datenformat Schritt für Schritt und finden Sie einen zusätzlichen Platz, wo es nicht hätte sein sollen.