How to send datetime values in SOAP request from Outsystems to a third party service

Hi All,

I have a SOAP service consumed in Outsystems and trying to call an operation which is expecting a datetime, I am trying to send datetime from Outsystems (for testing TextToDateTime("2020-01-01")) and getting an error response from the SOAP service : 

"body": {http://www.w3.org/2005/xqt-errors}XPTY0004 [{http://xmlns.oracle.com/xdk/xquery/error}XPTY0004f]: "Object reference not set to an instance of an object. ({http://www.w3.org/2001/XMLSchema}untypedAtomic)": bad value for type element * nillable { {http://www.w3.org/2001/XMLSchema}anyType }


I tried in SOAP UI and able to succeed only when I pass a datetime value "2020-01-01T00:00:00Z"

I am not able to frame a similar datetime in Outsystems, I am getting datetime in the format "yyyy-MM-dd hh:mm:ss" by default. At the same time, I cannot force the SOAP service to change the datatype  from datetime to text for this input.

Any idea on how to fix this issue ?

Thanks,

KJ


Hi,

You have the same identical problem here: https://www.outsystems.com/forums/discussion/21027/problem-using-datetime-in-soap-webservice/ , with some sugestions.

Hope it helps :/


Hi Karthik,

Can you check what is the value being passed in the request? You can see the full request in the logs, depending on the Logging Level defined in Service Center.


Cheers,

Tiago.

Following up on Nélio's link, although you can't change the implementation of the SOAP Service, you may be able to "trick" the service by sending a Text field with the required format.


To do this:

  1. Download the WSDL implementation of the SOAP service, and edit the type of the required parameter from "xsd:dateTime" to "xsd:string":


  2. Refresh or re-import the WSDL in Service Studio to generate a new set of structures with the updated definition. The DateTime Structure attribute should now appear with type "Text";

  3. In your Service Studio code, set the Attribute value to the correct date format before invoking the service. Here, you can use the built-in FormatDateTime function:

    FormatDateTime(DateTimeVariable, "yyyy-MM-ddTHH:mm:ssZ"


The DateTime should now be sent in the required format.

Gonçalo Soares wrote:

Following up on Nélio's link, although you can't change the implementation of the SOAP Service, you may be able to "trick" the service by sending a Text field with the required format.


To do this:

  1. Download the WSDL implementation of the SOAP service, and edit the type of the required parameter from "xsd:dateTime" to "xsd:string":


  2. Refresh or re-import the WSDL in Service Studio to generate a new set of structures with the updated definition. The DateTime Structure attribute should now appear with type "Text";

  3. In your Service Studio code, set the Attribute value to the correct date format before invoking the service. Here, you can use the built-in FormatDateTime function:

    FormatDateTime(DateTimeVariable, "yyyy-MM-ddTHH:mm:ssZ"


The DateTime should now be sent in the required format.

Hi Goncalo,


I cannot update the WSDL and load it locally in Outsystems with my changes, If there are any updates in near future, I have to refresh the WSDL to pick those changes. Are there any other options ?


Similarly, How can I assign a datetime returned from a SOAP response in ISO format(yyyy-MM-ddTHH:mm:ssZ) to Outsystems datetime? I am getting errors while deserializing the SOAP response due to these two different formats? ISO datetime  --> Outsystems datetime 


Thanks for your suggestions

KJ 


Hi Karthik,

Just made a small test consuming a SOAP method with a DateTime input parameter, and the format used by OutSystems is pretty standard and should be accepted by the provider.

I got <NewDateTime>2019-12-10T14:53:48.1970000+00:00</NewDateTime>, wich is an acceptable way of representing UTC according to the norm.

I wonder if the provider only accepts date time values in the Zulu time format. If that's the case, you should alter the request before sending it. Please check Use Advanced Extensibility.


Cheers,

Tiago.

Karthik Jeyaraman wrote:

if there are any updates in near future, I have to refresh the WSDL to pick those changes. Are there any other options ?

You're correct, and this is an unfortunate limitation to this approach.


The alternative way actually depends on your OutSystems Platform version.

  • OutSystems 11 or higher: Use the Advanced Extensibility method Tiago has linked to.
    The documentation also links to this Forge sample to help get you started.
  • OutSystems 10 or lower: Consume the WebService via an Extension, exposing the webservice methods as Actions with appropriate Input/Output structures.

Both solutions require some coding in Integration Studio. I'm unsure whether Advanced Extensibility is available for Java platforms.


I am getting errors while deserializing the SOAP response due to these two different formats

This is strange, I've been able to consume this DateTime format from SOAP services in the past.

Can you share the Service Center error and the XML Response?