We are enabling few custom web services through Apex to insert data into custom objects. Here we have different data types like Double, Date, Boolean, String.

For the inputs of any type except String, the service call is failing if we don't pass any values in those input parameters.

Is there a way to configure allow nulls for those parameters? Can I directly change the XML in WSDL to accept nulls?


Write a webservice class like this

global with sharing class CaseWebserviceClassTemp
    global class MyCaseInfo 
        webservice String Description;
        webservice Long textId = null;

    //actual method to insert the Case into SFDC
    webservice static String createNewCasesTemp(CaseWebserviceClassTemp.MyCaseInfo caseInformation)
        //logic goes here
        return null;

Now, generate WSDL

<xsd:complexType name="MyCaseInfo">
    <xsd:element name="Description" minOccurs="0" type="xsd:string" nillable="true"/>
    <xsd:element name="textId" minOccurs="0" type="xsd:long" nillable="true"/>

Here textId which is Long, will accept null.

Refer Representations of null in XML Schema

| improve this answer | |
  • Thanks for the reply. Can you please share sample input XML for above service. Should I skip the textId parameter in the input XML when we send it? Or is there an attribute i need to set for that parameter? – Lucky Feb 23 '18 at 5:18
  • create this class and generate wsdl and then import this wsdl in Soap UI – Santanu Boral Feb 23 '18 at 5:20
  • @Boral, yeah I was testing as sepcified by you. What I'm looking for is, when I have to pass the null value, how the XML should be. Like, I need to remove that textId paramter from my input XML or should I follow a way like <td:textId /> or <tf:textId xsi:nil="true"/> or some other ..? – Lucky Feb 23 '18 at 5:40

Not the answer you're looking for? Browse other questions tagged or ask your own question.