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
bvramkumarbvramkumar 

Communicating with an Apex webservice

Hi,

 

I am trying to communicate with a webservice hosted in one of the sandbox Org.s using SOAPUI(desktop tool). This tool gives me the below request structure

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sl="http://soap.sforce.com/schemas/class/XXXXXXXXXXXXXXXX">
   <soapenv:Header>
      <sl:AllowFieldTruncationHeader>
         <sl:allowFieldTruncation></sl:allowFieldTruncation>
      </sl:AllowFieldTruncationHeader>
      <sl:DebuggingHeader>
         <!--Zero or more repetitions:-->
         <sl:categories>
            <sl:category></sl:category>
            <sl:level></sl:level>
         </sl:categories>
         <sl:debugLevel></sl:debugLevel>
      </sl:DebuggingHeader>
      <sl:CallOptions>
         <sl:client></sl:client>
      </sl:CallOptions>
      <sl:SessionHeader>
         <sl:sessionId>XXXXXXXXXXX!AQgAQDClDsbFptrQ5zWifnhNyIf2WI4HwvF49kZbOUr7Y59MTSPnUZCuHUULR7T8gbIs239c9Df0yXg5PYsUl.ixIuRqA4ji</sl:sessionId>
      </sl:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <sl:updateAssetRecords>
         <!--Zero or more repetitions:-->
         <sl:Asset_Utilization>
            <!--Optional:-->
            <sl:Fusion_Id>12345</sl:Fusion_Id>
            <!--Optional:-->
            <sl:Product_SKU>12345</sl:Product_SKU>
            <!--Optional:-->
            <sl:UtilizationBucket1>12345</sl:UtilizationBucket1>
            <!--Optional:-->
            <sl:UtilizationBucket2>12345</sl:UtilizationBucket2>
            <!--Optional:-->
            <sl:UtilizationBucket3>12345</sl:UtilizationBucket3>
            <!--Optional:-->
            <sl:UtilizationBucket4>12345</sl:UtilizationBucket4>
            <!--Optional:-->
            <sl:UtilizationBucket5>12345</sl:UtilizationBucket5>
            <!--Optional:-->
            <sl:UtilizationBucket6>12345</sl:UtilizationBucket6>
            <!--Optional:-->
            <sl:UtilizationDescription>12345</sl:UtilizationDescription>
         </sl:Asset_Utilization>
      </sl:updateAssetRecords>
   </soapenv:Body>
</soapenv:Envelope>

When I am submitting the above request it returns me the below response with Error message in it.

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <soapenv:Fault>
         <faultcode>soapenv:Client</faultcode>
         <faultstring>'' is not valid for type xsd:boolean, should be '0', '1', 'true' or 'false'</faultstring>
      </soapenv:Fault>
   </soapenv:Body>
</soapenv:Envelope>

 

Can someone please help me to resolve the error?

 

 

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell
sl:allowFieldTruncation is a boolean field that requires a true or false value, an empty element is not valid, either add a value or remove that header entirely

All Answers

digamber.prasaddigamber.prasad

Hi,

 

Looks like one of field from below code snippet  is of Boolean data type in salesforce. Could you please cross check your salesforce org for this.

 

<sl:Fusion_Id>12345</sl:Fusion_Id>
            <!--Optional:-->
            <sl:Product_SKU>12345</sl:Product_SKU>
            <!--Optional:-->
            <sl:UtilizationBucket1>12345</sl:UtilizationBucket1>
            <!--Optional:-->
            <sl:UtilizationBucket2>12345</sl:UtilizationBucket2>
            <!--Optional:-->
            <sl:UtilizationBucket3>12345</sl:UtilizationBucket3>
            <!--Optional:-->
            <sl:UtilizationBucket4>12345</sl:UtilizationBucket4>
            <!--Optional:-->
            <sl:UtilizationBucket5>12345</sl:UtilizationBucket5>
            <!--Optional:-->
            <sl:UtilizationBucket6>12345</sl:UtilizationBucket6>
            <!--Optional:-->
            <sl:UtilizationDescription>12345</sl:UtilizationDescription>

 

Let me know if you need detail information around this.

 

Regards,

Digamber Prasad

 

bvramkumarbvramkumar
They are all string parameters.
SuperfellSuperfell
sl:allowFieldTruncation is a boolean field that requires a true or false value, an empty element is not valid, either add a value or remove that header entirely
This was selected as the best answer
digamber.prasaddigamber.prasad

Hi,

 

Could you please share wsdl with me?

 

Regards,

Digamber Prasad

bvramkumarbvramkumar

Thanks Simon. that worked. Also I was able to remove the unnecessary parameters from Request and it became successful. Thanks so much for pointing it out. So the actual requst that worked is below. This presses on the importance of checking the SOAP header before sending request.

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sl="http://soap.sforce.com/schemas/class/xxxxxxxxxxxxxxx">
   <soapenv:Header>
      <sl:AllowFieldTruncationHeader>
         <sl:allowFieldTruncation>1</sl:allowFieldTruncation>
      </sl:AllowFieldTruncationHeader>
      <sl:CallOptions>
         <sl:client></sl:client>
      </sl:CallOptions>
      <sl:SessionHeader>         <sl:sessionId>xxxxxxxxxxxxxAQgAQAskyMFHt3RS9pSuFrUrtTxC.HpyJiQzILSp1BcXz0Ew02LZQo1zSEfTsfi7ePhUsv18rRc2zkuJXAbfdBsHdMcve2Py</sl:sessionId>
      </sl:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <sl:updateAssetRecords>
         <!--Zero or more repetitions:-->
         <sl:Asset_Utilization>
            <!--Optional:-->
            <sl:Fusion_Id>12345</sl:Fusion_Id>
            <!--Optional:-->
            <sl:Product_SKU>12345</sl:Product_SKU>
            <!--Optional:-->
            <sl:UtilizationBucket1>12345</sl:UtilizationBucket1>
            <!--Optional:-->
            <sl:UtilizationBucket2>12345</sl:UtilizationBucket2>
            <!--Optional:-->
            <sl:UtilizationBucket3>12345</sl:UtilizationBucket3>
            <!--Optional:-->
            <sl:UtilizationBucket4>12345</sl:UtilizationBucket4>
            <!--Optional:-->
            <sl:UtilizationBucket5>12345</sl:UtilizationBucket5>
            <!--Optional:-->
            <sl:UtilizationBucket6>12345</sl:UtilizationBucket6>
            <!--Optional:-->
            <sl:UtilizationDescription>12345</sl:UtilizationDescription>
         </sl:Asset_Utilization>
      </sl:updateAssetRecords>
   </soapenv:Body>
</soapenv:Envelope>

 

bvramkumarbvramkumar

As simon also indicated that we can remove unnecessary or optional :) tags from soap header. I removed all of them except sessionId and it worked... :)

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sl="http://soap.sforce.com/schemas/class/xxxxxxxxxxxxx">
   <soapenv:Header>
   
      <sl:SessionHeader>
         <sl:sessionId>xxxxxxxxxxxxxx!AQgAQAskyMFHt3RS9pSuFrUrtTxC.HpyJiQzILSp1BcXz0Ew02LZQo1zSEfTsfi7ePhUsv18rRc2zkuJXAbfdBsHdMcve2Py</sl:sessionId>
      </sl:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <sl:updateAssetRecords>
         <!--Zero or more repetitions:-->
         <sl:Asset_Utilization>
            <!--Optional:-->
            <sl:Fusion_Id>12345</sl:Fusion_Id>
            <!--Optional:-->
            <sl:Product_SKU>12345</sl:Product_SKU>
            <!--Optional:-->
            <sl:UtilizationBucket1>12345</sl:UtilizationBucket1>
            <!--Optional:-->
            <sl:UtilizationBucket2>12345</sl:UtilizationBucket2>
            <!--Optional:-->
            <sl:UtilizationBucket3>12345</sl:UtilizationBucket3>
            <!--Optional:-->
            <sl:UtilizationBucket4>12345</sl:UtilizationBucket4>
            <!--Optional:-->
            <sl:UtilizationBucket5>12345</sl:UtilizationBucket5>
            <!--Optional:-->
            <sl:UtilizationBucket6>12345</sl:UtilizationBucket6>
            <!--Optional:-->
            <sl:UtilizationDescription>12345</sl:UtilizationDescription>
         </sl:Asset_Utilization>
      </sl:updateAssetRecords>
   </soapenv:Body>
</soapenv:Envelope>

If any one wants to why some parts of the XML above are masked with XXXXXXX, the first masking in xmlns:sl url is my webservice class name and the second masking with XXXXXXXXXXXX is my Org.Id.