4

I have some trouble submitting user data to a server by using Soap. All i get is:
Error Fetching http body, No Content-Length, connection closed or chunked data Am i doing something wrong?

$client = new SoapClient(APPPATH.'my.wsdl',array(
    'login' => 'user',
    'password' => 'pass',
    'location' => 'http://gimmeyadata.com/crm/regserv?wsdl',
    'trace' => true,
    )
);
$result = $client->register(array(
    'Email' => 'me@mail.com',
    'Gender' => 'm',
    'First name' => 'Oliver',
    'Last name' => 'Liermann',
    'Language code' => 'de-de',
));

Last response header: HTTP/1.1 200 OK X-SiteConfidence: jenppb601 Content-Location: http://.***.*/general/html/pages/layouts/columnContent.jsp Content-Language: de-DE Content-Type: text/html;charset=UTF-8 Date: Fri, 18 May 2012 15:50:01 GMT Transfer-Encoding: chunked Connection: keep-alive Connection: Transfer-Encoding Set-Cookie: JSESSIONID=0a6d28f530d798c4676f59494491a82035d98e25ff6f.e38Ka38Sax4TbO0MaheKbhaTbh8Te6fznA5Pp7ftolbGmkTy; path=/ Cache-Control: private

Last request header: POST /html/de_DE/index_DE/index.html HTTP/1.1 Host: .**.* Connection: Keep-Alive User-Agent: PHP-SOAP/5.2.13 Content-Type: text/xml; charset=utf-8 SOAPAction: "" Content-Length: 937 Authorization: Basic c3RyZ19ka29zaGF2ZTpsNFB3TVZqDlRhZUc1cg== Cookie: JSESSIONID=0a6e28e930d70301b8f6dd3e8a2598bff7cef065809a.e38Pa3mLbx4Oci0Mah4Qb34TbxmOe6fznA5Pp7etoltGmkTy;BIGipServerPirobase=254438666.20480.0000;

PHP Version: 5.2.13

OLee
  • 41
  • 1
  • 5
  • Which PHP version are you using, and if you enable the soap trace, please post the response header. – hakre May 18 '12 at 12:40

3 Answers3

17

try PHP 5.3 with

$client = new SoapClient("< some url  >", 
    array(
        'trace' => 1,
        'stream_context' => stream_context_create(
            array(
                'http' => array(
                    'protocol_version' => 1.0,
                ),
            )
        ),
    )
);
yunzen
  • 32,854
  • 11
  • 73
  • 106
amir
  • 171
  • 1
  • 3
2

With PHP 5.4.4, it didn't work without Transfer-Encoding: chunked :

$client = new SoapClient("< some url  >", 
    array(
        'trace' => 1,
        'stream_context' => stream_context_create(
            array(
                'http' => array(
                    'protocol_version' => 1.0,
                    'header' => "Transfer-Encoding: chunked\r\n",
                ),
            )
        ),
    )
);
yunzen
  • 32,854
  • 11
  • 73
  • 106
Menencia
  • 1,289
  • 1
  • 12
  • 23
0

I was having trouble with UPS Shipping API

This was my SoapClient before

$client = new SoapClient("Your URL or Manifest", 
array(
    'soap_version'  => 'SOAP_1_1',
    'trace' => 1
)

);

This fixed the problem (I'm using PHP 7.2)

$client = new SoapClient("Your URL or Manifiest", 
array(
    'trace' => 1,
    'stream_context' => stream_context_create(
        array(
            'http' => array(
                'protocol_version' => 1.0,
            ),
        )
    ),
)

);