POST /xxxxxxxxxxxx/ws/commonservice.asmx HTTP/1.1
ホスト: 202.82.66.147
コンテンツタイプ: text/xml; charset=utf-8
Content-Length: 長さ
SOAPAction: "http://xxxxxxxxxxxxxx/webservices/queryVoyageRoute_onWeb"
<ソープ:ボディ>
<ポート会社コード>文字列ポート会社コード>
----------------------------------------------- --------------------------------------
戻り:
HTTP/1.1 200 OK
コンテンツ-タイプ: テキスト/xml; charset=utf-8
Content-Length: 長さ
<ソープ:ボディ>
----------------------------------------------- ----------------------------------
<?php$client = new SoapClient('http://xxxxxxxxxxxxx/ws/commonservice.asmx?WSDL');//这个SOAP地址要换成你自己的$client->soap_defencoding = 'utf-8'; $client->decode_utf8 = false; $client->xml_encoding = 'utf-8'; $setoffdate=array(0=>"setoffdate",1=>"2014-02-10"); $fromportcode=array(0=>"fromportcode",1=>"SK");$toportcode=array(0=>"toportcode",1=>"ZH");$parameters=array(0=>$setoffdate,1=>$fromportcode,2=>$toportcode);$param = array(0=>$parameters,1=>"SKG",2=>"E");//$param["param1"]="01";//$param["param2"]="02";//$result = $client->__soapCall("GetArticle", array( $param ));$result = $client->__Call("queryVoyageRoute_onWeb", array( $param ));if (is_soap_fault($result)){ trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);}else{ $data = $result->queryVoyageRoute_onWebResult ; //这里返回的是类,必须使用->得到元素的值 print_r($data); //$city_xml = simplexml_load_string($city); }?>
你先检查 queryVoyageRoute_onWebResult 否か拼写错误 没错则:
WSDL が見られないため、正しいパラメータがどのように記述されるかわからない
パラメータは 1 つの関連数グループ (关)联键はWSDL)、
は複数のグループの 1 つである可能性がありますが、1 つの複数のグループの下位の数グループである可能性があります。么能知道、他
$param = array('parameters'=>$parameters,'portcompanyCode'=>"SKG",'lang'=>"C");
SOAP 嘛,当然 utf-8 的啦
航班情報?
$クライアント- >xml_encoding = 'utf-8';
此处不是已经xml_encoding = 'utf-8'; 了吗?何还是乱码?
SOAP 嘛,当然是 utf-8 的啦
航班信息?
header("content-type:text/html;charset=utf-8");
没错,是 utf-8 的
你当 gbk 显示当然就乱码了
没错,是 utf-8 的
你当 gbk 显示当然就乱码了
上面的多了一个.
print_r($child->toport).;
用 simplexml_load_string 加载得到的都是 SimpleXMLElement 对象
具体要如何分析要是具体的数据而定
你可以贴出 $result 并说明需求
页面结果:
蛇口港?仔客运码头SKMAC金星JX2014-02-10 09:30MSK-MAC普通位(28)头等位(5)特等位(8)SKG蛇口港?仔客运码头SKMAC金星JX2014-02-10 09:30MSK-MAC普通位(28)头等位(5)特等位(8)XYLC蛇口港?仔客运码头SKMAC金星JX2014-02-10 09:30MSK-MAC普通位(28)头等位(5)特等位(8)SHYG蛇口港?仔客运码头SKMAC金星JX2014-02-10 09:30MSK-MAC普通位(28)头等位(5)特等位(8)SJCD蛇口港?仔客运码头SKMAC金星JX2014-02-10 09:30MSK-MAC普通位(28)头等位(5)特等位(8)BAKY蛇口港?仔客运码头SKMAC金星JX2014-02-10 09:30MSK-MAC普通位(28)头等位(5)特等位(8)ZYJD蛇口港?仔客运码头SKMAC金星JX2014-02-10 09:30MSK-MAC普通位(28)头等位(5)特等位(8)YJGY
结果源文件:
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"><NewDataSet xmlns=""><Table diffgr:id="Table1" msdata:rowOrder="0"><FROMPORT>蛇口港</FROMPORT><TOPORT>?仔客运码头</TOPORT><FPORTCODE>SK</FPORTCODE><TPORTCODE>MAC</TPORTCODE><SHIP>金星</SHIP><SHIPCODE>JX</SHIPCODE><SETOFFTIME>2014-02-10 09:30</SETOFFTIME><SELLSTATUS>M</SELLSTATUS><LINECODE>SK-MAC</LINECODE><TICKETNUM>普通位(28)头等位(5)特等位(8)</TICKETNUM><CLIENTCODE>SKG</CLIENTCODE></Table><Table diffgr:id="Table2" msdata:rowOrder="1"><FROMPORT>蛇口港</FROMPORT><TOPORT>?仔客运码头</TOPORT><FPORTCODE>SK</FPORTCODE><TPORTCODE>MAC</TPORTCODE><SHIP>金星</SHIP><SHIPCODE>JX</SHIPCODE><SETOFFTIME>2014-02-10 09:30</SETOFFTIME><SELLSTATUS>M</SELLSTATUS><LINECODE>SK-MAC</LINECODE><TICKETNUM>普通位(28)头等位(5)特等位(8)</TICKETNUM><CLIENTCODE>XYLC</CLIENTCODE></Table><Table diffgr:id="Table3" msdata:rowOrder="2"><FROMPORT>蛇口港</FROMPORT><TOPORT>?仔客运码头</TOPORT><FPORTCODE>SK</FPORTCODE><TPORTCODE>MAC</TPORTCODE><SHIP>金星</SHIP><SHIPCODE>JX</SHIPCODE><SETOFFTIME>2014-02-10 11:00</SETOFFTIME><SELLSTATUS>M</SELLSTATUS><LINECODE>SK-MAC</LINECODE><TICKETNUM>普通位(42)头等位(31)特等位(0)</TICKETNUM><CLIENTCODE>YJGY</CLIENTCODE></Table><Table diffgr:id="Table43" msdata:rowOrder="42"><FROMPORT>蛇口港</FROMPORT><TOPORT>?仔客运码头</TOPORT><FPORTCODE>SK</FPORTCODE><TPORTCODE>MAC</TPORTCODE><SHIP>迅隆5</SHIP><SHIPCODE>XL5</SHIPCODE><SETOFFTIME>2014-02-10 11:00</SETOFFTIME><SELLSTATUS>M</SELLSTATUS><LINECODE>SK-MAC</LINECODE><TICKETNUM>普通位(42)头等位(31)特等位(0)</TICKETNUM><CLIENTCODE>SKXRD</CLIENTCODE></Table><Table diffgr:id="Table44" msdata:rowOrder="43"><FROMPORT>蛇口港</FROMPORT><TOPORT>?仔客运码头</TOPORT><FPORTCODE>SK</FPORTCODE><TPORTCODE>MAC</TPORTCODE><SHIP>迅隆5</SHIP><SHIPCODE>XL5</SHIPCODE><SETOFFTIME>2014-02-10 19:00</SETOFFTIME><SELLSTATUS>M</SELLSTATUS><LINECODE>SK-MAC</LINECODE><TICKETNUM>普通位(148)头等位(7)特等位(8)</TICKETNUM><CLIENTCODE>SCP</CLIENTCODE></Table></NewDataSet></diffgr:diffgram>
用 simplexml_load_string 加载得到的都是 SimpleXMLElement 对象
具体要如何分析要是具体的数据而定
你可以贴出 $result 并说明需求
$key = array('FROMPORT', 'TOPORT', 'SETOFFTIME');foreach($obj_xml->NewDataSet->Table as $item) { foreach($key as $k) { $t[$k] = strval($item->$k); } $res[] = $t;}print_r($res);
Array( [0] => Array ( [FROMPORT] => 蛇口港 [TOPORT] => ?仔客运码头 [SETOFFTIME] => 2014-02-10 09:30 ) [1] => Array ( [FROMPORT] => 蛇口港 [TOPORT] => ?仔客运码头 [SETOFFTIME] => 2014-02-10 09:30 ) [2] => Array ( [FROMPORT] => 蛇口港 [TOPORT] => ?仔客运码头 [SETOFFTIME] => 2014-02-10 11:00 ) [3] => Array ( [FROMPORT] => 蛇口港 [TOPORT] => ?仔客运码头 [SETOFFTIME] => 2014-02-10 11:00 ) [4] => Array ( [FROMPORT] => 蛇口港 [TOPORT] => ?仔客运码头 [SETOFFTIME] => 2014-02-10 19:00 ))
$key = array('FROMPORT', 'TOPORT', 'SETOFFTIME');foreach($obj_xml->NewDataSet->Table as $item) { foreach($key as $k) { $t[$k] = strval($item->$k); } $res[] = $t;}print_r($res);
Array( [0] => Array ( [FROMPORT] => 蛇口港 [TOPORT] => ?仔客运码头 [SETOFFTIME] => 2014-02-10 09:30 ) [1] => Array ( [FROMPORT] => 蛇口港 [TOPORT] => ?仔客运码头 [SETOFFTIME] => 2014-02-10 09:30 ) [2] => Array ( [FROMPORT] => 蛇口港 [TOPORT] => ?仔客运码头 [SETOFFTIME] => 2014-02-10 11:00 ) [3] => Array ( [FROMPORT] => 蛇口港 [TOPORT] => ?仔客运码头 [SETOFFTIME] => 2014-02-10 11:00 ) [4] => Array ( [FROMPORT] => 蛇口港 [TOPORT] => ?仔客运码头 [SETOFFTIME] => 2014-02-10 19:00 ))