rivaufa
@rivaufa

Как отправить SOAP запрос через PHP?

Нужно отправить такой запрос через PHP и получить ответ. Как это сделать? Soap клиент на сервере есть.
<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>

Вот пока что получилось:
$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")));


Все равно ошибка 500, не получается. что не так?(
  • Вопрос задан
  • 1061 просмотр
Пригласить эксперта
Ответы на вопрос 1
@krypt3r
php.net/soapclient
Изучайте
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы