function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
zirosziros 

Passing null from apex class to external webservice.

Hello,
I search and found the fieldsToNull, but I can't get how to work with it.
 
I have apex class which calls to webservice, and I want to pass parameter of type Datetime with null value
to .net webservice.
 
how to do it ?
 
TIA
 
 
 
RickyGRickyG
ziros -

According to the Apex doc, you should not have to use fieldsToNull with Apex.  Have you tried simply setting the value to null?


zirosziros

Hi, When Im passing null within apex class and pass a datetime parameter which is null this is the error I'm getting

 

System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: System.Web.Services.Protocols.SoapException: ‏‏לשרת לא היתה אפשרות לקרוא את הבקשה. ---> System.InvalidOperationException: Error in  XML (1, 416). ---> System.FormatException: המחרוזת ‏‏'' אינה ערך AllXsd חוקי.‏
   ב-  System.Xml.Schema.XsdDateTime..ctor(String text, XsdDateTimeFlags kinds)
   ב-  System.Xml.XmlConvert.ToDateTime(String s, XmlDateTimeSerializationMode dateTimeOption)
   ב-  System.Xml.Serialization.XmlCustomFormatter.ToDateTime(String value)
   ב-  System.Xml.Serialization.XmlSerializationReader.ToDateTime(String value)
   ב-  Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read8_IchlusProtocolUpdate()
   ב-  Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer8.Deserialize(XmlSerializationReader reader)
   ב-  System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   --- סוף רכיב מעקב אחר מחסנית של מצב חריג פנימי ---
   ב-  System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   ב-  System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
   ב-  System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
   --- סוף רכיב מעקב אחר מחסנית של מצב חריג פנימי ---
   ב-  System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
   ב-  System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest() faultcode=soap:Client faultactor=

Class.WSIchlusSalesForce.ServiceIchlusSoap.IchlusProtocolUpdate: line 134, column 13
Class.WSIchlusSalesForceHelper.UpdateIchlusProtocol: line 244, column 9

TIA for help on this
SuperfellSuperfell
Does the service WSDL allow for the dateTime to be nilable ?
zirosziros

Hi Simon, guess you pointing in the right direction,

The webservice is an ASP.NET webservice and here is small section of its WSDL from wich the apex class is created

 

- <s:element name="IchlusProtocolUpdate">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="opportunityID" type="s:string" />
  <s:element minOccurs="1" maxOccurs="1" name="orderNumber" type="s:double" />
  <s:element minOccurs="1" maxOccurs="1" name="institCode" type="s:int" />
  <s:element minOccurs="1" maxOccurs="1" name="expectedArrivalDate" type="s:dateTime" />
  </s:sequence>
  </s:complexType>
  </s:element>
 
if you check the expectedArrivalDate it seems there is no nillable attribute ,is that what you mean ?
 
if so how can one make this attribute appear ?
 
TIA
zirosziros

Solved : well seems like the answer was simple

In asp.net (im using framework 2)  instead of defining just : DateTime somevar

need to define wiht nullable like this Datetime? somevar and than the WSDL includes the nillable="true"