1

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?

closed as off-topic by battery.cord, Martin Lezer, glls, Boris Bachovski, Himanshu Feb 22 '18 at 4:16

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on problems in code you've written must describe the specific problem and include valid code to reproduce it. For help writing short, self-contained syntactically-valid examples, see: SSCCE.org" – battery.cord, Martin Lezer, glls, Boris Bachovski, Himanshu
If this question can be reworded to fit the rules in the help center, please edit the question.

2

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:sequence>
    <xsd:element name="Description" minOccurs="0" type="xsd:string" nillable="true"/>
    <xsd:element name="textId" minOccurs="0" type="xsd:long" nillable="true"/>
    </xsd:sequence>
</xsd:complexType>

Here textId which is Long, will accept null.

Refer Representations of null in XML Schema

  • 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.