1

I'm getting the following error:

Fatal error: Uncaught SoapFault exception: [s:Client] Service operation Pickup_Cancel failed due to validation errors: Input is null

Here's my code:

$client = new SoapClient("https://etrack.postaplus.net/APIService/PostaWebClient.svc?singleWsdl", array("trace" => 1, "exception" => 0));

$params = array(
        "CodeStation" => `BEY`,
        "PickupNumber" => `1`,
        "Reason" => `test reason`,
        "Password" => `sss`,
        "ShipperAccount" => `acc`,
        "UserName" => `acc`,
    );

$client->Pickup_Cancel($params);

1 Answer 1

2

The awnser to the question you didn't ask is probably: replace the backticks (`) by singlequotes (')

-- Edit. That was not the problem.

Here is the case. SOAP can be a pain to get going. My experience is to use a good soap class or just non-wsdl mode. Read up on this in the docs: https://www.php.net/manual/en/soapclient.soapcall.php

So don't do this:

$return = $soapClient->functionName($data);

But this:

$return = $soapClient->__SoapCall('functionName', $data);

Also get a grip on what the server wants, load the WSDL url into a client like SoapUI https://www.soapui.org/ (its free). This lets you check if the SoapServer works and how you should approach it with your call.

In your case the WSDL states this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:pos="http://schemas.datacontract.org/2004/07/PostaWebClient">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:Pickup_Cancel>
         <!--Optional:-->
         <tem:CLIENTINFO>
            <!--Optional:-->
            <pos:CodeStation>asd</pos:CodeStation>
            <!--Optional:-->
            <pos:Password>asd</pos:Password>
            <!--Optional:-->
            <pos:ShipperAccount>asd</pos:ShipperAccount>
            <!--Optional:-->
            <pos:UserName>asd</pos:UserName>
         </tem:CLIENTINFO>
         <!--Optional:-->
         <tem:PickupNumber>asd</tem:PickupNumber>
         <!--Optional:-->
         <tem:Reason>asd</tem:Reason>
      </tem:Pickup_Cancel>
   </soapenv:Body>
</soapenv:Envelope>

Which translates to this PHP code:

$client = new SoapClient("https://etrack.postaplus.net/APIService/PostaWebClient.svc?singleWsdl");

$params = [
    'Pickup_Cancel' => [
        'CLIENTINFO' => [
            'Password' => 'sss',
            'ShipperAccount' => 'acc',
            'UserName' => 'acc',
            'CodeStation' => '',
        ],
        'PickupNumber' => '',
        'Reason' => '',
    ],
];

$client->__SoapCall("Pickup_Cancel", $params);

See how the array matches the WSDL xml format?

This should also give you the feedback you need to proceed. If not, its probably time to get 'real' help :) Goodluck.

Sign up to request clarification or add additional context in comments.

2 Comments

@AhmedSaeed well it was a guess and you still havent asked a real question. Perhaps you could provide some more info and a link to the documentation?
link of documentation is etrack.postaplus.net/CustomerPortal/Documentation/… Do you need any extra info?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.