A
A
Alina2018-04-26 13:26:29
SOAP
Alina, 2018-04-26 13:26:29

How to send a SOAP request via PHP?

You need to send such a request through PHP and get a response. How to do it? There is a soap client on the server.

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://pegast.com/pegasys/api/IPackageSearchService/GetOptions</Action>
    <h:ApiUserKey xmlns:h="http://pegast.com/pegasys/api">XXX</h:ApiUserKey>
    <h:PreferredLanguageCode i:nil="true" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:h="http://pegast.com/pegasys/api" />
  </s:Header>
  <s:Body>
    <PackageSearchOptionsRequest xmlns="http://pegast.com/pegasys/api">
      <Parameters xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <DepartureLocationId i:nil="true" />
        <DestinationCountryId i:nil="true" />
        <Groups>Directions</Groups>
        <HotelIds xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />
        <MarketIds xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />
        <PackageId i:nil="true" />
        <PackageTypeIds xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />
        <ReturnHotelOptionsWithAttributes>false</ReturnHotelOptionsWithAttributes>
        <ReturnHotelOptionsWithMeals>false</ReturnHotelOptionsWithMeals>
        <ReturnLocationId i:nil="true" />
        <ReturnPastDepartureDates>false</ReturnPastDepartureDates>
      </Parameters>
    </PackageSearchOptionsRequest>
  </s:Body>
</s:Envelope>

Here's what happened so far:
$client = new SoapClient("https://api-ext-test.pegasys.pegast.com/PackageSearch.svc?singleWsdl");
$header = new SoapHeader('http://pegast.com/pegasys/api/IPackageSearchService/GetOptions', 'ApiKeyXX','RU');
$client->__setSoapHeaders($header);
print($client->GetOptions(PackageSearchOptionsRequest,array("Groups"=>"Directions")));

Still getting error 500, it doesn't work. what's wrong?(

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
krypt3r, 2018-04-26
@krypt3r

php.net/soapclient
Explore

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question