Excel 2016 Soap Web Service API Request

ghanchi2000

New Member
Joined
May 20, 2017
Messages
4
My Code
Code:
Private Sub Button1_Click() '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://webapp.tcscourier.com/codapi/Service1.asmx", False
    
 ' we create our SOAP envelope for submission to the Web Service
     sEnv = sEnv & "<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/"">"""
     sEnv = sEnv & "  <soapenv:Body>"
     sEnv = sEnv & "   <GetCNDetailsByReferenceNumber xmlns=""http://202.61.51.93:6265/"">"
     sEnv = sEnv & "    <userName>user</User>"
     sEnv = sEnv & "    <password>pass</Pwd>"
     'Looks for SKU in active worksheet cell B3
     sEnv = sEnv & "    <customerReferenceNo>" & Range("B3").Value & "</customerReferenceNo>"
     sEnv = sEnv & "   </GetCNDetailsByReferenceNumber>"
     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
    Range("B6").Value = Resp.SelectSingleNode("//GetCNDetailsByReferenceNumberResponse/GetCNDetailsByReferenceNumberResult").Text
    
  'clean up code
    Set Req = Nothing
    Set Resp = Nothing
    
    
End Sub

Request Code

HTML:
POST /codapi/Service1.asmx HTTP/1.1Host: webapp.tcscourier.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://202.61.51.93:6265/GetCNDetailsByReferenceNumber"


<?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>
    <GetCNDetailsByReferenceNumber xmlns="http://202.61.51.93:6265/">
      <userName>string</userName>
      <password>string</password>
      <customerReferenceNo>string</customerReferenceNo>
    </GetCNDetailsByReferenceNumber>
  </soap:Body>
</soap:Envelope>

Response Code
HTML:
HTTP/1.1 200 OKContent-Type: text/xml; charset=utf-8
Content-Length: length


<?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>
    <GetCNDetailsByReferenceNumberResponse xmlns="http://202.61.51.93:6265/">
      <GetCNDetailsByReferenceNumberResult>xmlxml</GetCNDetailsByReferenceNumberResult>
    </GetCNDetailsByReferenceNumberResponse>
  </soap:Body>
</soap:Envelope>


By running above code on Excel 2016 Windows 10 I get User Defined Type not defined

https://prnt.sc/jpd236

and how we can run this code in Google Sheet any one can help please
 
Last edited by a moderator:

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,214,819
Messages
6,121,741
Members
449,050
Latest member
excelknuckles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top