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
TariqKechTariqKech 

Error 411 - Callout Web Service

Hi,

 

I have a problem with an web service they hosted into IIS server.

 

Sometimes, IIS server reject my HTTP request because the header are not conform :

 

"Error 411 - Missed parameter content-lenght".

 

Can you help me ?

 

Best regards.

 

Call WS :

 

GetInfosClient.ClientResponse_element res = new GetInfosClient.ClientResponse_element();
GetInfosClient.BasicHttpBinding_ITwoWayAsync tb = new GetInfosClient.BasicHttpBinding_ITwoWayAsync();
res = tb.GetInfosClient('1234566','ORCC');

 

Sample Result KO :

 

Error 411 - Lenght requiered.

 

 

carlocarlo

You have a typo.

 

Content-Length is a standard param in a HTTP request.

 

You have written Content-Lenght twice in your post.

 

Is the typo in the error or in your post?

TariqKechTariqKech

Hello,

 

Execuse me, this is a typo in my post.

 

In the Log file of IIS, the error is "Content-Length missed".

 

Thank you for your help.

 

 

carlocarlo

Wierd.  I thought that was sent by default.  Can you show the code for creating the http response?

TariqKechTariqKech

I have generate the class of the webservice with the WSDL provided by Biztalk (ETL).

 

This is the call method :

 

// Result Structure

GetInfosClient.ClientResponse_element res = new GetInfosClient.ClientResponse_element();

// WebService
GetInfosClient.BasicHttpBinding_ITwoWayAsync tb = new GetInfosClient.BasicHttpBinding_ITwoWayAsync();

// Invoke WebService
res = tb.GetInfosClient('1234566','ORCC');

 

 

Thanks.

carlocarlo

OK not sure what that means.  I do it like this:

 

HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();

req.setEndpoint('http://your-url');
req.setMethod('POST');
req.setBody('Body=stuff');
req.setCompressed(true); // otherwise we hit a limit of 32000
req.setHeader('extra-header-name', 'extra-header-value'); 

 

try {
    res = http.send(req);
} catch(System.CalloutException e) {
     System.debug('Callout error: '+ e);
}

TariqKechTariqKech

We have don't invoke the Webservice en HTTP but with the WSDL.

 

10% of the callout didn't work with this webservice (ETL : Biztalk + Server : IIS).

 

This is the call generated with the WSDL :

 

//Generated by wsdl2apex

public class GetInfosClient {
    public class Insee_element {
        public String Siret;
        public String CodeApe;
        public String CodeInsee;
        private String[] Siret_type_info = new String[]{'Siret','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] CodeApe_type_info = new String[]{'CodeApe','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] CodeInsee_type_info = new String[]{'CodeInsee','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://CrmPart.Pivot_ClientResponse','false','false'};
        private String[] field_order_type_info = new String[]{'Siret','CodeApe','CodeInsee'};
    }
    public class Status_Technique_element {
        public String SyncStatus;
        public String ErrCode;
        public String ErrMessage;
        private String[] SyncStatus_type_info = new String[]{'SyncStatus','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] ErrCode_type_info = new String[]{'ErrCode','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] ErrMessage_type_info = new String[]{'ErrMessage','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://CrmPart.Pivot_ClientResponse','false','false'};
        private String[] field_order_type_info = new String[]{'SyncStatus','ErrCode','ErrMessage'};
    }
    public class ClientRequest_element {
        public String numClientLDE;
        public String origine;
        private String[] numClientLDE_type_info = new String[]{'numClientLDE','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] origine_type_info = new String[]{'origine','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://CrmPart.Pivot_ClientRequest','false','false'};
        private String[] field_order_type_info = new String[]{'numClientLDE','origine'};
    }
    public class Client_element {
        public String Civilite;
        public String Prenom;
        public String Nom;
        public String EstClientLDE;
        public String NumClientLDE;
        public String DateNaissance;
        public String EstClientIndirect;
        private String[] Civilite_type_info = new String[]{'Civilite','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] Prenom_type_info = new String[]{'Prenom','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] Nom_type_info = new String[]{'Nom','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] EstClientLDE_type_info = new String[]{'EstClientLDE','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] NumClientLDE_type_info = new String[]{'NumClientLDE','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] DateNaissance_type_info = new String[]{'DateNaissance','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] EstClientIndirect_type_info = new String[]{'EstClientIndirect','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://CrmPart.Pivot_ClientResponse','false','false'};
        private String[] field_order_type_info = new String[]{'Civilite','Prenom','Nom','EstClientLDE','NumClientLDE','DateNaissance','EstClientIndirect'};
    }
    public class Coordonnees_element {
        public String Telephone;
        public String Mobile;
        public String Fax;
        public String Email;
        public String StopEmail;
        private String[] Telephone_type_info = new String[]{'Telephone','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] Mobile_type_info = new String[]{'Mobile','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] Fax_type_info = new String[]{'Fax','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] Email_type_info = new String[]{'Email','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] StopEmail_type_info = new String[]{'StopEmail','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://CrmPart.Pivot_ClientResponse','false','false'};
        private String[] field_order_type_info = new String[]{'Telephone','Mobile','Fax','Email','StopEmail'};
    }
    public class Patrimoine_Client_element {
        public String RaccordementRue;
        public String RaccordementVille;
        public String RaccordementPostal;
        public String RaccordementRegion;
        public String RaccordementPays;
        public String TypeLogement;
        private String[] RaccordementRue_type_info = new String[]{'RaccordementRue','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] RaccordementVille_type_info = new String[]{'RaccordementVille','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] RaccordementPostal_type_info = new String[]{'RaccordementPostal','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] RaccordementRegion_type_info = new String[]{'RaccordementRegion','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] RaccordementPays_type_info = new String[]{'RaccordementPays','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] TypeLogement_type_info = new String[]{'TypeLogement','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://CrmPart.Pivot_ClientResponse','false','false'};
        private String[] field_order_type_info = new String[]{'RaccordementRue','RaccordementVille','RaccordementPostal','RaccordementRegion','RaccordementPays','TypeLogement'};
    }
    public class Equipements_element {
        public String PointComptage;
        public String CompteurEquipement;
        public String CompteurEmplacement;
        public String CompteurDomaine;
        private String[] PointComptage_type_info = new String[]{'PointComptage','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] CompteurEquipement_type_info = new String[]{'CompteurEquipement','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] CompteurEmplacement_type_info = new String[]{'CompteurEmplacement','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] CompteurDomaine_type_info = new String[]{'CompteurDomaine','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://CrmPart.Pivot_ClientResponse','false','false'};
        private String[] field_order_type_info = new String[]{'PointComptage','CompteurEquipement','CompteurEmplacement','CompteurDomaine'};
    }
    public class ClientResponse_element {
        public GetInfosClient.Client_element Client;
        public GetInfosClient.Coordonnees_element Coordonnees;
        public GetInfosClient.Insee_element Insee;
        public GetInfosClient.Patrimoine_Client_element Patrimoine_Client;
        public GetInfosClient.Equipements_element Equipements;
        public GetInfosClient.Status_Technique_element Status_Technique;
        private String[] Client_type_info = new String[]{'Client','http://CrmPart.Pivot_ClientResponse','Client_element','1','1','false'};
        private String[] Coordonnees_type_info = new String[]{'Coordonnees','http://CrmPart.Pivot_ClientResponse','Coordonnees_element','1','1','false'};
        private String[] Insee_type_info = new String[]{'Insee','http://CrmPart.Pivot_ClientResponse','Insee_element','1','1','false'};
        private String[] Patrimoine_Client_type_info = new String[]{'Patrimoine_Client','http://CrmPart.Pivot_ClientResponse','Patrimoine_Client_element','1','1','false'};
        private String[] Equipements_type_info = new String[]{'Equipements','http://CrmPart.Pivot_ClientResponse','Equipements_element','1','1','false'};
        private String[] Status_Technique_type_info = new String[]{'Status_Technique','http://CrmPart.Pivot_ClientResponse','Status_Technique_element','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://CrmPart.Pivot_ClientResponse','false','false'};
        private String[] field_order_type_info = new String[]{'Client','Coordonnees','Insee','Patrimoine_Client','Equipements','Status_Technique'};
    }
    public class BasicHttpBinding_ITwoWayAsync {
        public String endpoint_x = Constants.WS_ENDPOINT_IEM_GETINFOCLIENT;
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x = 60000;
        private String[] ns_map_type_info = new String[]{'http://CrmPart.Pivot_ClientResponse', 'GetInfosClient', 'http://tempuri.org/', 'GetInfosClient', 'http://CrmPart.Pivot_ClientRequest', 'GetInfosClient'};
        public GetInfosClient.ClientResponse_element GetInfosClient(String numClientLDE,String origine) {
            GetInfosClient.ClientRequest_element request_x = new GetInfosClient.ClientRequest_element();
            GetInfosClient.ClientResponse_element response_x;
            request_x.numClientLDE = numClientLDE;
            request_x.origine = origine;
            Map<String, GetInfosClient.ClientResponse_element> response_map_x = new Map<String, GetInfosClient.ClientResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'GetInfosClient',
              'http://CrmPart.Pivot_ClientRequest',
              'ClientRequest',
              'http://CrmPart.Pivot_ClientResponse',
              'ClientResponse',
              'GetInfosClient.ClientResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x;
        }
    }
}

 

 

 

carlocarlo

I'm guessing now.

 

Do you have 

 

@future (callout=true)

 

at the start of the class which calls

 

GetInfosClient.ClientResponse_element res = new GetInfosClient.ClientResponse_element();
GetInfosClient.BasicHttpBinding_ITwoWayAsync tb = new GetInfosClient.BasicHttpBinding_ITwoWayAsync();
res = tb.GetInfosClient('1234566','ORCC');

TariqKechTariqKech

Not really !

 

This Webservice is called on a VisualForce Controller.

 

I have posted just a sample of the callout that use for my test in the developper consol.

 

I used a future method for my callout :

 

 public PageReference callWSGetInfosClient(){
        Lead l;
        boolean isReqValid = true;
        GetInfosClient.BasicHttpBinding_ITwoWayAsync tb = new GetInfosClient.BasicHttpBinding_ITwoWayAsync();
        GetInfosClient.ClientResponse_element res;
        try{
            if (!system.Test.isRunningTest()){
                    tb.timeout_x =  60000; 
                    res = tb.GetInfosClient(numClientLDE, origine);
                }
        }
        catch (exception e ){
            isReqValid = false;
        }
}

 

carlocarlo

I thought you could not use callouts on a VF controller.  I have a callout which I could not use from a controller so I had to move it to a trigger.

klalwani1.393888107353561E12klalwani1.393888107353561E12
Did you find the resolution? I am facing a similar issue..