Forum Discussion

Christian Berge's avatar
Christian Berge
Copper Contributor
Apr 26, 2018

Trouble with Excel SOAP request

Hi all

 

I have made a macro in Excel to make a simple SOAP request to a web service. However, the server respons with an error message, saying SystemUserID cannot be zero. But I have set it to a value in my code, so I don't understand why I get this error Message.

 

This is my code. I have censored the value of SystemUserID, but in my code I have an actual number there:

 

Const xml = _
    "<?xml version='1.0' encoding='utf-8'?>" + _
    "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'  xmlns:xsd='http://www.w3.org/2001/XMLSchema'  xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>" + _
    "    <soap:Body>" + _
    "        <ListShortContractsPublishedForExportXMLBusinessIntelligence xmlns='http://*************'>" + _
    "            <SystemUserID>*********</SystemUserID>" + _
    "            <LanguageID>0</LanguageID>" + _
    "            <LastChangedDate>2018-01-01</LastChangedDate>" + _
    "            <ContractID>0</ContractID>" + _
    "            <SupplierID>0</SupplierID>" + _
    "            <ContractStatusID>0</ContractStatusID>" + _
    "            <VersionNumber>0</VersionNumber>" + _
    "            <IncludeClosedOrUnpublishedContracts>true</IncludeClosedOrUnpublishedContracts>" + _
    "        </ListShortContractsPublishedForExportXMLBusinessIntelligence>" + _
    "    </soap:Body>" + _
    "</soap:Envelope>"

  
    Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
   
    With xmlhttp
        .Open "POST", "https://***********", False
        .setRequestHeader "Host", "***********"
        .setRequestHeader "Content-Type", "text/xml; charset=utf-8"
        .setRequestHeader "Content-Length", LenB(xml)
        .setRequestHeader "SOAPAction", "http://***************"
        .send xml
    End With
   
   
    Debug.Print xmlhttp.responseText

 

Can anyone help?

No RepliesBe the first to reply