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
Dinesh KhandelwalDinesh Khandelwal 

illegal assignment error while invoking my webservice class

Hi All,
I have created a webservice class
global class PublishBBProvisioningEvents{
	webService static String sendIPAddress(String extId, 
                                                           String serviceName,
                                                           Boolean isDynamic, 
                                                           String IPRouteString ) {
	
		Provisioning_Updates__c orderUpdaterecord = new Provisioning_Updates__c();
	       
	        if(extId!=null) orderUpdaterecord.extId__c = extId;
		if(serviceName!=null) orderUpdaterecord.Service_name__c = name;
		if(isDynamic!=null) orderUpdaterecord. isDynamic__c = isDynamic;
		if(IPRouteString!=null) orderUpdaterecord. IP_iprecord__c=IPRouteString;
	       insert orderUpdaterecord;
	       return 'SUCCESS';
	}
}
When client application sends all values in same sequence, it works well. But if client application do not send values in sequence or don’t send second parameter, it throws illegal assignment  from Boolean to string error

if they send below , it works well
 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pub="http://soap.sforce.com/schemas/class/PublishBBProvisioningEvents">
   <soapenv:Header>
      <pub:SessionHeader>
         <pub:sessionId>00D110000006EVE!ARMAQA8XOw62xM17pgWzDOq9fJMbPkHeKB7PvcbNFiCClV4onxTzVRl2EH7FyCyZTNhFOrxIIpJY2cw4w0md9dkXpuAO2lyu</pub:sessionId>
      </pub:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <pub:sendIPAddress>
         <pub:extId>954899952</pub:extId>
         <pub:serviceName>1234</pub:serviceName>
         <pub:isDynamic>true</pub:isDynamic>
         <pub:IPRouteString>10.12.23.34/28</pub:IPRouteString>
      </pub:sendIPAddress>
   </soapenv:Body>
</soapenv:Envelope>

but if they send below, it throws error
 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pub="http://soap.sforce.com/schemas/class/PublishBBProvisioningEvents">
   <soapenv:Header>
      
      <pub:SessionHeader>
         <pub:sessionId>00D110000006EVE!ARMAQA8XOw62xM17pgWzDOq9fJMbPkHeKB7PvcbNFiCClV4onxTzVRl2EH7FyCyZTNhFOrxIIpJY2cw4w0md9dkXpuAO2lyu</pub:sessionId>
      </pub:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <pub:sendIPAddress>
         <pub:extId>954899952</pub:extId>
         <pub:isDynamic>true</pub:isDynamic>
         <pub:IPRouteString>10.12.23.34/28</pub:IPRouteString>
      </pub:sendIPAddress>
   </soapenv:Body>
</soapenv:Envelope>

Or the below
 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pub="http://soap.sforce.com/schemas/class/PublishBBProvisioningEvents">
   <soapenv:Header>
      
      <pub:SessionHeader>
         <pub:sessionId>00D110000006EVE!ARMAQA8XOw62xM17pgWzDOq9fJMbPkHeKB7PvcbNFiCClV4onxTzVRl2EH7FyCyZTNhFOrxIIpJY2cw4w0md9dkXpuAO2lyu</pub:sessionId>
      </pub:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <pub:sendIPAddress>
         <pub:extId>954899952</pub:extId>
         <pub:isDynamic>true</pub:isDynamic>
	 <pub:serviceName>1234</pub:serviceName>
         <pub:IPRouteString>10.12.23.34/28</pub:IPRouteString>
      </pub:sendIPAddress>
   </soapenv:Body>
</soapenv:Envelope>

Can anyone suggest what the problem is?

Thanks
Dinesh
 
Mikola SenykMikola Senyk
Hi Dinesh,

The problem is that all apex webservice parameters are mandatory. You cannot skip anyone of them.
Try to change SOAP message with xsi:nil=”true” (don’t forget the xsi namespace in the envelope):
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pub="http://soap.sforce.com/schemas/class/PublishBBProvisioningEvents" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Header>
      
      <pub:SessionHeader>
         <pub:sessionId>00D110000006EVE!ARMAQA8XOw62xM17pgWzDOq9fJMbPkHeKB7PvcbNFiCClV4onxTzVRl2EH7FyCyZTNhFOrxIIpJY2cw4w0md9dkXpuAO2lyu</pub:sessionId>
      </pub:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <pub:sendIPAddress>
         <pub:extId>954899952</pub:extId>
         <pub:serviceName xsi:nil="true" />
         <pub:isDynamic>true</pub:isDynamic>
         <pub:IPRouteString>10.12.23.34/28</pub:IPRouteString>
      </pub:sendIPAddress>
   </soapenv:Body>
</soapenv:Envelope>