douyan1613 2013-09-06 06:24
浏览 146
已采纳

PHP中的Soap API集成:SoapClient错误

When I use the XML in sopaUI the results are coming out fine, but when I use the following php code the the result comes out blank and I get this error: Fatal error: Uncaught SoapFault exception: [soap:Server] System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Saia.Presentation. I think the problem is in the Soap header or something because when I comment out the parameters there's no change in the result.

Link from where I got the wsdl file and schema: http://www.saiasecure.com/webservice/pickup/n_Create.asp

$client = new SoapClient("http://www.saiasecure.com/webservice/pickup/soap.asmx?wsdl",array( 'trace' => 1,
'exceptions' => true,'features' => SOAP_SINGLE_ELEMENT_ARRAYS, ));

$params = array("UserID" => '*******',
        "Password" => '*****',
        "TestMode" => "Y",
        "AccountNumber" => '******',
        "CompanyName" => 'TESTING NAME',
        "Street" => 'TESTING STREET',
        "Box" => 'TESTING BOX',
        "City" => 'LOS ANGELES',
        "State" => 'CA',
        "Zipcode" => '90001',
        "ContactName" => 'TESTING CONTACT',
        "ContactPhone" => '1234567890',
        "PickupDate" => '2013-09-24',
        "ReadyTime" => '13:00:00',
        "CloseTime" => '17:00:00',
        "SpecialInstructions" => 'Nothing',
         "Details" => array("DetailItem" => array("DestinationZipcode" => '70364', "Pieces" => '5', "Package" => 'SK',"Weight" => '100', "Freezable" => 'N') ));
    //print('<pre>');print_r($params);  
$return = $client->Create($params);
  • 写回答

1条回答 默认 最新

  • douhui9631 2013-09-06 07:37
    关注

    If you take a look to the WSDL you'll see that the Create operation parameter must contain a request element that points to the actual Create object parameter (that you can send as you did with an associative array).

    I must say that the WSDL is not very correct because the same element name, meaning Create is used twice for a different définition. Once as element, once as complexType.

    To be clear, you have to do so with your actual code : $return = $client->Create(array('request'=>$params)); and it should work.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀