Forum Discussion

greenkey's avatar
greenkey
New Contributor
11 years ago

Soap Webservice: dealing with nulls

Hi all,

I'm having some trouble trying to call a WS.

 

I need to test an error message when the request has a null element.

I found that in SOAPUI you have to set a "xsi:nil" property to "true" for the tag you want to make null, but I don't know how to make it with TestComplete.

 

This is part of my VBScript code:

 

  ...

  Dim Service: Service = "myservice"
  Dim Method: Method = "mymethod"

  Dim WSName: WSName = "myWS"

  ' preparing the input
  Set RequestObj = UtilWS.WSinit( Service, Method )
  RequestObj.before = Null ' this is a Date field
  Set ServiceInfo = WebServices.CreateWebServiceInfoFromItem( WSName )
  Set RequestXml = ServiceInfo.PrepareRequest( MethodName, RequestObj )

  log.Message "Request ready", RequestXml.xml

  ...

 

Tthe tag "before" is not in the xml...

 

How can I tell "PrepareRequest" to use the "xsi:nil" attribute for the Null tags?

 

Thanks

  • Hi Lorenzo,

     

    If you already have a ready SoapUI test, you can call it from TestComplete. Starting since TC 10.6, the product has the Ready! API and SoapUI Integration feature. Please read the "Integration With Ready! API and SoapUI" ( http://smartbear.com/viewarticle/66716/ ) help topic for more information.

  • AlexKaras's avatar
    AlexKaras
    Icon for Champion Level 3 rankChampion Level 3

    Hi,

     

    I am just guessing what is done inside the WSinit() function, but have you tried

    RequestObj.before = "xsi:nil" ?

     

    If it does not help, can you provide the code for WSinit() and the contents of the service WSDL file?

    • greenkey's avatar
      greenkey
      New Contributor

      TanyaYatskovska wrote:

      Hi Lorenzo,

       

      If you already have a ready SoapUI test, you can call it from TestComplete. Starting since TC 10.6, the product has the Ready! API and SoapUI Integration feature. Please read the "Integration With Ready! API and SoapUI" ( http://smartbear.com/viewarticle/66716/ ) help topic for more information.


      Thanks Tanya,

      i tried integrating SOAPUI but I have do do some programmatic checks and other things within a script.

      I kno I can do a lot of things with SOAPUI but we have a lot of codebase already written for TestComplete and at the moment we don't want to switch all to SOAPUI.


      AlexKaras wrote:

      Hi,

       

      I am just guessing what is done inside the WSinit() function, but have you tried

      RequestObj.before = "xsi:nil" ?


      With this command I'm telling to put the value "xsi:nil" in the attribute before, that is a Date.

      The interpreter says me something like "Type mismatch" (I have the italian version that says "Tipo non corrispondente")


      If it does not help, can you provide the code for WSinit() and the contents of the service WSDL file?


       Sorry for that, this is my WSInit

       

      ' =============================================================================
      ' retrieve WS information and returns the request ready to be sent
      ' inspired by http://support.smartbear.com/viewarticle/56393/
      ' REQUIRE: a WebService definition named WSName
      Function WSinit( WSName, MethodName )
        Dim ServiceInfo, RequestObj
        ' Initialise the service information from the project's WebServices
        Set ServiceInfo = WebServices.CreateWebServiceInfoFromItem( WSName )
        
        ' Create an object with the method's input parameters
        Set RequestObj = ServiceInfo.PrepareRequestObject( MethodName )
        
        Set WSinit = RequestObj
      end Function