Error consuming webservice with SoapClient PHP

4

I am trying to consume a web service with SoapClient PHP, I have made several tests but the only answer I get is the following error:

  

The server was unable to process the request due to an internal error.   For more information about the error, either turn on   IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute   or from the configuration behavior) on the server in order to send the   exception information back to the client, or turn on tracing as per   the Microsoft .NET Framework SDK documentation and inspect the server   trace logs.

The developers of the webservice tell me that it is not their error. I would appreciate someone if you can help me with this error since I do not have much experience with webservice. Thanks in advance.

The php code is as follows:

$WebService = "http://factulaar.grupolaar.com:9019/ClsWaybill.svc?wsdl";

$client = new SoapClient($WebService, array('trace' => 1));

$parametros = array(
    'ActualWeight' => '2',
    'Branch' => 'Quito',
    'ClientWeight' => '3',
    'Comments' => 'Testing WebService',
    'Company' => '10',
    'ContentSdtl' => 'Testing Contents',
    'CustomerId' => '01346',
    'DeclaredValue' => '100',

    'DeliveryAddress' => array(
        'AddressLine1' => 'Calle 1 22-13',
        'AddressLine2' => 'Calle 2',
        'City' => 'Cuenca',
        'Country' => 'Ecu',
        'Name' => 'Juan Pérez',
        'Phone' => '123456789',
        'State' => 'Azuay',
        'ZipCode' => '0',
    ),

    'ElectronicWeight' => '5',
    'GUIANumber' => '',
    'Height' => '10',
    'Idtrx' => '75',
    'Length' => '10',
    'Password' => 'TEST',
    'PickUpConsignee' => '52307',
    'PickupRequestDate' => '05/20/2016',
    'Pieces' => '1',
    'Service' => 'CRG',
    'UnitDimension' => 'CM',
    'Username' => 'WEBSERVICE',
    'Warehouseid' => 'QUITO',
    'Warehouseidloc' => '',
    'WeightUnit' => 'KG',
    'Width' => '10',
);

try
{
    $WS = new SoapClient($WebService, array("trace" => 1));
    $result = $WS->CreateWayBill($parametros1);
}
catch(SoapFault $exception)
{
    echo $exception->getMessage();
}
    
asked by Josue Aguirre 06.06.2016 в 18:15
source

1 answer

2

First of all, you do not put the SOAP protocol version using 1_1 or 1_2. Although that might not be the problem put it. Then I think the problem is your arrangement. If the WS is in .Net, you can not send arrays of arrays, that does not exist in .NET. To communicate they should be like this:

$WebService= new SoapClient("http://factulaar.grupolaar.com:9019/ClsWaybill.svc?wsdl", 
                    array('trace' => 1,'soap_version' => SOAP_1_1));
$arreglo=array('parametro1'=>$parametro1,'parametro2'=>$parametro2, ...);//PuedenSerVarios
$respuesta = $WebService->__soapCall('CreateWayBill',array($arreglo));

Still, this code could have something because I do not know the documentation, but I think it would be more or less like that. If you send an array this should go as a vector since .Net does not understand the PHP arrays.

Edited:

Look, I think it would be like that (you have to create a WayBill class with those properties ) and then:

$WebService= new SoapClient("http://factulaar.grupolaar.com:9019/ClsWaybill.svc?wsdl", 
                    array('trace' => 1,'soap_version' => SOAP_1_1));    
$wayBill=new WayBill(); 
$wayBill->ActualWeight=$valor1; 
$wayBill->Branch=$valor2; 
//etc. Así con el resto de los campos 
$arreglo=array('objWayBillDetails'=>$wayBill);
$respuesta = $WebService->__soapCall('CreateWayBill',array($arreglo));
    
answered by 06.06.2016 / 19:43
source