Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8786365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:36:17+00:00 2026-06-13T21:36:17+00:00

I’m facing this problem from some days but still i can’t find any answer

  • 0

I’m facing this problem from some days but still i can’t find any answer or solution either on the net or to my previous question (wich actually had some errors).

That’s the scenario. I have to consume gls webservice to add parcel or list inserted parcel.
I’m using curl to construct client and make the call, here is the code from the class:

/*Headers*/
public function buildGlsHeaders($glsCall,$gls_lenght,$soap_action)
{       
    //header soap 1.1
    $headers = array(
        "Content-Type: text/xml; charset=utf-8",
        "Content-Length: " . $gls_lenght,
        $soap_action,
        );

    return $headers;
}

/*Request*/
public function sendRequest($glsCall, $requestBody, $gls_lenght, $soap_action)
{
    $cookiePath = tempnam('/tmp', 'cookie');

    //build gls headers using variables passed via constructor as well as the gls call to use
    $headers = $this->buildGlsHeaders($glsCall, $gls_lenght, $soap_action);

    //initialise a CURL session
    $connection = curl_init();

    //set the server we are using 
    curl_setopt($connection, CURLOPT_URL, 'http://weblabeling.gls-italy.com/IlsWebService.asmx');

    //Time out
    curl_setopt($connection, CURLOPT_CONNECTTIMEOUT, 10);
    curl_setopt($connection, CURLOPT_TIMEOUT, 10);

    //set it to return the transfer as a string from curl_exec
    curl_setopt($connection, CURLOPT_RETURNTRANSFER, true);

    //stop CURL from verifying the peer's certificate
    curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, false);

    //set method as POST
    curl_setopt($connection, CURLOPT_POST, true);

    //set the XML body of the request
    curl_setopt($connection, CURLOPT_POSTFIELDS, $requestBody);

    //set the headers using the array of headers
    curl_setopt($connection, CURLOPT_HTTPHEADER, $headers);

    //Header
    curl_setopt($connection, CURLINFO_HEADER_OUT, true);
    curl_setopt($connection, CURLOPT_HEADER, true);

    curl_setopt($connection, CURLOPT_COOKIEJAR, $cookiePath);

    //Send the Request
    $response = curl_exec($connection);

    print_r(curl_getinfo($connection));

    echo "\n" . 'Header Code: ' . curl_getinfo($connection, CURLINFO_HTTP_CODE) . "\n\n";

    //close the connection
    curl_close($connection); 

    //return the response
    return $response;
}

Variables $glsCall, $requestBody, $gls_lenght, $soap_action come from the script itself:

$soap_action = "SOAPAction: \"http://weblabeling.gls-italy.com/AddParcel\"";

$gls_lenght = strlen($xml); 

and the request is sent by the line:

/*AddParcel*/
$glsResponse = $gls->sendRequest('AddParcel', $xml, $gls_lenght, $soap_action);

/*ListSped*/
$glsResponse = $gls->sendRequest('ListSped', $xml, $gls_lenght, $soap_action);

Now both calls are constructed in the same way, but one of them is nested:

$Label = array(
                'XMLInfoParcel' => array(
                'Info' => array(
                    'SedeGls' => $SedeGls,
                    'CodiceClienteGls' => $CodiceClienteGls,
                    'PasswordClienteGls' => $PasswordClienteGls,                
                    'Parcel' => array(
                                       'CodiceContrattoGls' => $cod_cont,
                                       'RagioneSociale' => $rag_soc,
                                       'Indirizzo' => $delivery_indirizzo,
                                       'Localita' => $delivery_city,
                                       'Zipcode' => $data['delivery_postcode'],
                                       'Provincia' => $data['zone_code'],
                                       'Bda' => '',
                                       'DataDocumentoTrasporto' => '',
                                       'Colli' => '1',
                                       'Incoterm' => '',
                                       'PesoReale' => '1,00',
                                       'ImportoContrassegno' => $imp_cont,
                                       'NoteSpedizione' => $data['customers_telephone'],
                                       'TipoPorto' => 'F',
                                       'Assicurazione' => $ass_ins,
                                       'PesoVolume' => '',
                                       'TipoCollo' => $tipo_collo,
                                       'FrancoAnticipata' => '',
                                       'RiferimentoCliente' => '',
                                       'NoteAggiuntive' => '',
                                       'CodiceClienteDestinatario' => '',
                                       'Email' => '',
                                       'Cellulare1' => $telefono,
                                       'Cellulare2' => '',
                                       'ServiziAccessori' => '',
                                       'ModalitaIncasso' => $mod_inc    
                                  ),),),                                
                );

and the other one is not:

/*Request*/
    $listsp = array(
                    'SedeGls' => $SedeGls,
                    'CodiceClienteGls' => $CodiceClienteGls,
                    'PasswordClienteGls' => $PasswordClienteGls 
                    );

those are requested input:

AddParcel

enter image description here

List Sped

enter image description here

As you can see the input format is different, here is the schema of AddParcel “string”

enter image description here

It continues with other fields and close with

       </Parcel>
  </Info>

ListSped call works perfectly while AddParcel doesn’t, it always return a 400 Bad request header.
I assume xml is correct since i sent it to GLS IT support and they confirm me it works when uploaded directly. Unfortunatly they don’t give support for php.

I was thinking about the nested array causing the problem but i don’t feel like possible since if i change xml structure webservice answers correctly: “xml structure is wrong”.

I’ve been looking around and i found some other people with the same problems but no solutions is found. I would like to make the script works in php instead of using other languages wich i don’t really know anything about.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T21:36:19+00:00Added an answer on June 13, 2026 at 9:36 pm

    As we can see in picture ‘AddParcel’ of requested input the input itself is a string.

    I realized that it wants it to be formatted as:

        &lt;Info&gt;&lt;SedeGls&gt;XXX&lt;/SedeGls&gt;&lt;CodiceContrattoGls&gt;XXX&lt;/CodiceContrattoGls&gt; <!--and so on-->
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
Does anyone know how can I replace this 2 symbol below from the string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.