12 years ago
Webservice testing
I am trying to generate soap request using the PrepareRequest method given in TestComplete Webservices api.
But some of elements in the serviceRequestXML is not present when returned by the prepareRequest method. I have verified the requestObject before passing to the method and the values are present in it. Please find the attached WSDL and the script.
In the serviceXML the <lead/> object is getting empty. LeadData is Any type object and the value is set with an xml read from a file. PrepareRequest method doesn't include the xml set on LeadData and also it doesn't throw any errors when the method is called.
Is this a bug in the TestComplete or am I missing anything? Please advice me.
here is the wsdl: https://qaleads2.autobase.net/DMXIntegrations/DMXIntegrations.asmx
The Code below:
Sub WebServiceMethodTest
Dim MethodName
Dim ServiceInfo, RequestObj, RequestXml,URL, ServiceName, SoapVersion
Dim ArrayObj
Dim Root, HeaderNode, CredentialsNode, UserIDNode, PasswordNode
Dim HeaderElement, CredentialsElement, UserIDElement, PasswordElement
Dim UserIDValue, PasswordValue
Dim XmlHttpRequest
' Specify the name of the web service method to be tested
MethodName = "AddOEMNewLead"
'Specifies the URL address of the web service's WSDL document
URL = "https://qaleads2.autobase.net/DMXIntegrations/DMXIntegrations.asmx?WSDL"
' Specifies the web service's name
ServiceName = "DMXIntegrations"
' Specifies the protocol version to be used
SoapVersion = WebServices.svSoap11
' Obtains the WebServiceInfo object
Set ServiceInfo = WebServices.CreateWebServiceInfo(URL, ServiceName, SoapVersion)
Dim TypeFactory
'Get the type factory for the web service
Set TypeFactory = WebServices.TestWebService.TypeFactory
Set LeadEntity = TypeFactory.TestLeadEntity
LeadEntity.OemType = "Ford"
LeadEntity.Type = "QA"
'Set TestLeadEntity.LeadData = TypeFactory.LeadDataType
Set obj1 = TypeFactory.LeadDataType
Set obj = CreateXMLObj("C:\Leads\FordLead.xml")
Set obj1.Any = obj
Set LeadEntity.LeadData = obj1
'Create an object with the method's input parameters
Set RequestObj = ServiceInfo.PrepareRequestObject(MethodName)
RequestObj.passkey = "Susmitha"
Set RequestObj.lead = LeadEntity
' Make an XML document for the SOAP request
Set RequestXml = ServiceInfo.PrepareRequest(MethodName, RequestObj)
Log.message RequestXml.XML
' Modify the XML data and add a SOAP header with credentials
Set Root = RequestXml.documentElement
'Create an XMLHTTP object for sending the SOAP request
Set XmlHttpRequest = CreateObject("MSXML2.XMLHTTP.3.0")
' Send the created SOAP request to the web service
Call XmlHttpRequest.open("POST", "https://qaleads2.autobase.net/DMXIntegrations/DMXIntegrations.asmx", False)
Call XmlHttpRequest.send(RequestXml)
Set ResponseXML = XmlHttpRequest.responseXML
Log.Message ResponseXML.XML
End Sub
Thanks,
Shell
But some of elements in the serviceRequestXML is not present when returned by the prepareRequest method. I have verified the requestObject before passing to the method and the values are present in it. Please find the attached WSDL and the script.
In the serviceXML the <lead/> object is getting empty. LeadData is Any type object and the value is set with an xml read from a file. PrepareRequest method doesn't include the xml set on LeadData and also it doesn't throw any errors when the method is called.
Is this a bug in the TestComplete or am I missing anything? Please advice me.
here is the wsdl: https://qaleads2.autobase.net/DMXIntegrations/DMXIntegrations.asmx
The Code below:
Sub WebServiceMethodTest
Dim MethodName
Dim ServiceInfo, RequestObj, RequestXml,URL, ServiceName, SoapVersion
Dim ArrayObj
Dim Root, HeaderNode, CredentialsNode, UserIDNode, PasswordNode
Dim HeaderElement, CredentialsElement, UserIDElement, PasswordElement
Dim UserIDValue, PasswordValue
Dim XmlHttpRequest
' Specify the name of the web service method to be tested
MethodName = "AddOEMNewLead"
'Specifies the URL address of the web service's WSDL document
URL = "https://qaleads2.autobase.net/DMXIntegrations/DMXIntegrations.asmx?WSDL"
' Specifies the web service's name
ServiceName = "DMXIntegrations"
' Specifies the protocol version to be used
SoapVersion = WebServices.svSoap11
' Obtains the WebServiceInfo object
Set ServiceInfo = WebServices.CreateWebServiceInfo(URL, ServiceName, SoapVersion)
Dim TypeFactory
'Get the type factory for the web service
Set TypeFactory = WebServices.TestWebService.TypeFactory
Set LeadEntity = TypeFactory.TestLeadEntity
LeadEntity.OemType = "Ford"
LeadEntity.Type = "QA"
'Set TestLeadEntity.LeadData = TypeFactory.LeadDataType
Set obj1 = TypeFactory.LeadDataType
Set obj = CreateXMLObj("C:\Leads\FordLead.xml")
Set obj1.Any = obj
Set LeadEntity.LeadData = obj1
'Create an object with the method's input parameters
Set RequestObj = ServiceInfo.PrepareRequestObject(MethodName)
RequestObj.passkey = "Susmitha"
Set RequestObj.lead = LeadEntity
' Make an XML document for the SOAP request
Set RequestXml = ServiceInfo.PrepareRequest(MethodName, RequestObj)
Log.message RequestXml.XML
' Modify the XML data and add a SOAP header with credentials
Set Root = RequestXml.documentElement
'Create an XMLHTTP object for sending the SOAP request
Set XmlHttpRequest = CreateObject("MSXML2.XMLHTTP.3.0")
' Send the created SOAP request to the web service
Call XmlHttpRequest.open("POST", "https://qaleads2.autobase.net/DMXIntegrations/DMXIntegrations.asmx", False)
Call XmlHttpRequest.send(RequestXml)
Set ResponseXML = XmlHttpRequest.responseXML
Log.Message ResponseXML.XML
End Sub
Thanks,
Shell