肥皂1.2请求与PHP

时间:2019-04-08 08:33:42

标签: php soap

我对Soap Server的请求有问题: https://weblabeling.gls-italy.com/ilswebservice.asmx?WSDL enter image description here

这是我的参数:

<?php
$params = array(
                 'XMLInfoParcel' => array(
                            'Info' => array(
                                'SedeGls' => $sede_GLS,
                                'CodiceClienteGls' => $codice_cliente,
                                'PasswordClienteGls' => $password_gls,
                                'Parcel' => array(
                                                   'CodiceContrattoGls' => $codice_contratto,
                                                   'RagioneSociale' => $destinatario,
                                                   'Indirizzo' => $adress,
                                                   'Localita' => $city,
                                                   'Zipcode' => $cap,
                                                   'Provincia' => $provincia,
                                                   'Bda' => $order_number,
                                                   'Colli' => '1',
                                                   'Incoterm' => '',
                                                   'PesoReale' => '3',
                                                   'ImportoContrassegno' => $imp_cont,
                                                   'NoteSpedizione' => 'prove note',
                                                   'TipoPorto' => 'F',
                                                   'Assicurazione' => '',
                                                   'PesoVolume' => '',
                                                   'TipoCollo' => '0',
                                                   'FrancoAnticipata' => '',
                                                   'RiferimentoCliente' => '',
                                                   'NoteAggiuntive' => 'prova',
                                                   'CodiceClienteDestinatario' => '',
                                                   'Email' => $email,
                                                   'Cellulare1' => $phone,
                                                   'ServiziAccessori' => '',
                                                   'ModalitaIncasso' => 'CONT',
                                                   'DataPrenotazioneGDO' => '',
                                                    'OrarioNoteGDO' => '',
                                                    'GeneraPdf' => '0',
                                                    'ContatoreProgressivo' => '',
                                                    'IdentPIN' => '',
                                                    'AssicurazioneIntegrativa' => '',
                                                    'TipoSpedizione' => '',
                                                    'ValoreDichiarato' => '',
                                                    'PersonaRiferimento' => '',
                                                    'Contenuto' => '',
                                                    'TelefonoDestinatario' => '',
                                                    'CategoriaMerceologica' => '',
                                                    'FatturaDoganale' => '',
                                                    'DataFatturaDoganale' => '',
                                                    'PezziDichiarati' => '',
                                                    'NazioneOrigine' => '',
                                                    'TelefonoMittente' => ''
                                                  ),),),
                    );

<?php 

       $client = new SoapClient('https://weblabeling.gls-italy.com/ilswebservice.asmx?WSDL', array('soap_version' => SOAP_1_2));
        // populate the inputs....


            $params = crea_spedizione();

$result = $client->AddParcel($params);


$array = json_decode(json_encode($result), true);
$xml = simplexml_load_string($result->AddParcelResult->any);

响应为xml不兼容 我也尝试与邮政 但我有同样的问题。 XML生成正在运行。 maby的问题是xml文件,请求服务器是格式文本,但我听不懂

1 个答案:

答案 0 :(得分:0)

带有意大利GLS网络服务的精细办公软件,用于添加PARCEL

$xml_good ='&lt;Info&gt;&lt;SedeGls&gt;XX&lt;/SedeGls&gt;&lt;CodiceClienteGls&gt;000000&lt;/CodiceClienteGls&gt;&lt;PasswordClienteGls&gt;passwr&lt;/PasswordClienteGls&gt;&lt;Parcel&gt;&lt;CodiceContrattoGls&gt;3743&lt;/CodiceContrattoGls&gt;&lt;RagioneSociale&gt;Raffaele Filomena&lt;/RagioneSociale&gt;&lt;Indirizzo&gt;Via Damiano Chiesa 7/c&lt;/Indirizzo&gt;&lt;Localita&gt;Carovigno&lt;/Localita&gt;&lt;Zipcode&gt;72012&lt;/Zipcode&gt;&lt;Provincia&gt;BR&lt;/Provincia&gt;&lt;Bda&gt;001234&lt;/Bda&gt;&lt;Colli&gt;1&lt;/Colli&gt;&lt;Incoterm&gt;&lt;/Incoterm&gt;&lt;PesoReale&gt;2&lt;/PesoReale&gt;&lt;/Parcel&gt;&lt;/Info&gt;';



        //Data, connection, auth
       // $dataFromTheForm = $_POST['fieldName']; // request data from the form
        $soapUrl = "https://labelservice.gls-italy.com/ilswebservice.asmx?op=AddParcel"; // asmx URL of WSDL


        // xml post structure

        $xml_post_string = '<?xml version="1.0" encoding="utf-8"?>
                            <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
                              <soap:Body>
                                <AddParcel xmlns="https://labelservice.gls-italy.com/">
                                  <XMLInfoParcel>'.$xml_good.'</XMLInfoParcel>
                                 </AddParcel>
                              </soap:Body>
                            </soap:Envelope>';   // data from the form, e.g. some ID number

           $headers = array(
                        "Content-type: text/xml;charset=\"utf-8\"",
                        "Accept: text/xml",
                        "Cache-Control: no-cache",
                        "Pragma: no-cache",
                        "SOAPAction: https://labelservice.gls-italy.com/AddParcel",
                        "Content-length: ".strlen($xml_post_string),
                    ); //SOAPAction: your op URL

            $url = $soapUrl;

            // PHP cURL  for https connection with auth
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
            curl_setopt($ch, CURLOPT_TIMEOUT, 10);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

            // converting
            $response = curl_exec($ch);
            curl_close($ch);


var_dump($response);

与GLS Webservice(Italty)一起添加包裹可以很好地工作,现在我尝试插入XML响应文件