POST /xxxxxxxxxxxx/ws/commonservice.asmx HTTP/1.1
Host: 202.82.66.147
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://xxxxxxxxxxxxxx/webservices/queryVoyageRoute_onWeb"
---------------------------------------------------------------------------------------
返回:
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: 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); }?>
提示错误:
Notice: Undefined property: stdClass::$queryVoyageRoute_onWebResult in D:\xampp\htdocs\WS\index.php on line 21
如何传参数过去类型不对?要怎么传过去呢?
回复讨论(解决方案)
你先检查 queryVoyageRoute_onWebResult 是否拼写错误
没错则:
print_r($result); 看看结果
如果结果不包含期望内容
则检查传递的参数是否正确
由于没有看到你的 WSDL,所以不知道正确的参数该如何写
参数应是一个关联数组(关联键是WSDL),可能还是多维的
而你的是一个多维的下标数组
我已经搞定了,把参数名加进去就可以。
$param = array('parameters'=>$parameters,'portcompanyCode'=>"SKG",'lang'=>"C");
但是,中文调出来的出现一片乱码,怎么能知道,他是用哪种编码呢?
???娓???捣涔?床娓?SKZH娴? ??KKJ2014-02-10 07:30MSK-ZH?????(65)缍????(27)?????(0)璐靛???(12)JLFZ???娓???捣涔?床娓?SKZH娴? ??KKJ2014-02-10 07:30MSK-ZH?????(65)缍????(27)?????(0)璐靛???(12)SJCD???娓???捣涔?床娓?SKZH娴? ??KKJ2014-02-10 07:30MSK-ZH?????(65)缍????(27)?????(0)璐靛???(12)XYLC???娓???捣涔?床娓?SKZH娴? ??KKJ2014-02-10 07:30MSK-ZH?????(65)缍????(27)?????(0)璐靛???(12)SKWEB???娓???捣涔?床娓?SKZH娴? ??KKJ2014-02-10 07:30MSK-ZH?????(65)缍????(27)?????(0)璐靛???(12)AYGJ???娓???捣涔?床娓?SKZH娴? ??KKJ2014-02-10 07:30MSK-ZH?????(65)缍????(27)?????(0)璐靛???(12)SHYG???娓???捣涔?床娓?SKZH娴? ??KKJ2014-02-10 07:30MSK-ZH?????(65)缍????(27)?????(0)璐靛???(12)BZLY???娓???捣涔?床娓?SKZH娴? ??KKJ2014-02-10 07:30MSK-ZH?????(65)缍????(27)?????(0)璐靛???(12)LHMT???娓???捣涔?床娓?SKZH娴? ??KKJ2014-02-10 07:30MSK-ZH?????(65)缍????(27)?????(0)璐靛???(12)STSJD???娓???捣涔?床娓?SKZH娴? ??KKJ2014-02-10 07:30MSK-ZH?????(65)缍????(27)?????(0)璐靛???(12)QSHK???娓???捣涔?床娓?SKZH娴? ??KKJ2014-02-10 07:30MSK-ZH?????(65)缍????(27)?????(0)璐靛???(12)KBSJ???娓???捣涔?床娓?SKZH娴? ??KKJ2014-02-10 07:30MSK-ZH?????(65)缍????(27)?????(0)璐靛???(12)YGJD???娓???捣涔?床娓?SKZH娴? ??KKJ2014-02-10 07:30MSK-ZH?????(65)缍????(27)?????(0)璐靛???(12)WYN???娓???捣涔?床娓?SKZH娴? ??KKJ2014-02-10 07:30MSK-ZH?????(65)缍????(27)?????(0)璐靛???(12)HGJD???娓???捣涔?床娓?SKZH娴? ??KKJ2014-02-10 07:30MSK-ZH?????(65)缍????(27)?????(0)璐靛???(12)TGGY???娓???捣涔?床娓?SKZH娴? ??KKJ2014-02-10 07:30MSK-ZH?????(65)缍????(27)?????(0)璐靛???(12)ZNHY???娓???捣涔?床娓?SKZH娴? ??KKJ2014-02-10 07:30MSK-ZH?????(65)缍????(27)?????(0)璐靛???(12)MHZX
SOAP 嘛,当然是 utf-8 的啦
航班信息?
SOAP 嘛,当然是 utf-8 的啦
航班信息?
$client->xml_encoding = 'utf-8';
此处不是已经xml_encoding = 'utf-8'; 了吗?为何还是乱码?
SOAP 嘛,当然是 utf-8 的啦
航班信息?
搞定了,请版本帮我把3楼的回复给删除,谢谢。
header("content-type:text/html;charset=utf-8");
没错,是 utf-8 的
你当 gbk 显示当然就乱码了
没错,是 utf-8 的
你当 gbk 显示当然就乱码了
版主,麻烦你再看看,为何,我想print_r个别的列的表值不行呢?全部是SimpleXMLElement Object ( )
上面的多了一个.
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 并说明需求
我只想print_r:FROMPORT、TOPORT、SETOFFTIME的字段信息
$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 ))
谢谢版主,麻烦版主把8楼的回复给删除,我一会结贴。

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Notepad++7.3.1
Easy-to-use and free code editor
