我对Soap Server的请求有问题: https://weblabeling.gls-italy.com/ilswebservice.asmx?WSDL
这是我的参数:
<?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文件,请求服务器是格式文本,但我听不懂
答案 0 :(得分:0)
带有意大利GLS网络服务的精细办公软件,用于添加PARCEL
$xml_good ='<Info><SedeGls>XX</SedeGls><CodiceClienteGls>000000</CodiceClienteGls><PasswordClienteGls>passwr</PasswordClienteGls><Parcel><CodiceContrattoGls>3743</CodiceContrattoGls><RagioneSociale>Raffaele Filomena</RagioneSociale><Indirizzo>Via Damiano Chiesa 7/c</Indirizzo><Localita>Carovigno</Localita><Zipcode>72012</Zipcode><Provincia>BR</Provincia><Bda>001234</Bda><Colli>1</Colli><Incoterm></Incoterm><PesoReale>2</PesoReale></Parcel></Info>';
//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响应文件