php soap client如何更改名称空间前缀? [英] php soap client How to change namespace prefix?

查看:138
本文介绍了php soap client如何更改名称空间前缀?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过汤客户端发送这样的xml:

I want send xml like this through the soup client:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:hot="http://TekTravel/HotelBookingApi">
   <soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
      <hot:Credentials UserName="test" Password="test@123"/>
      <wsa:Action>http://test/HotelBookingApi/CountryListRequest</wsa:Action>
      <wsa:To>http://api.test.in/HotelAPI_V7/HotelService.svc</wsa:To>
   </soap:Header>

   <soap:Body>
      <hot:CountryListRequest/>
   </soap:Body>
</soap:Envelope>

但是它发送这样的xml:

But it send xml like this:

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://TekTravel/HotelBookingApi">
    <env:Header>
        <ns1:Credentials UserName="test" Password="test@123"/>
        <ns1:Action>http://test/HotelBookingApi/HotelSearch</ns1:Action>
        <ns1:To>http://api.test.in/HotelAPI_V7/HotelService.svc</ns1:To>
    </env:Header>
    <env:Body>
        <ns1:CountryListRequest/>
    </env:Body>
</env:Envelope>

api需要与第一个完全相同的xml.我使用Laravel 5.2,这是我的代码:

api need exact same xml like the first one.I use Laravel 5.2 and this is my code:

<?php

namespace App\Model\Hotel;

use Illuminate\Database\Eloquent\Model;

use SoapClient;
use SoapHeader;
use SoapVar;

class HotelTBO extends Model
{

    //Credentials
    var $Credentials = ['UserName' => 'test', 'Password' => 'test@123'];

    //WSDL
    var $wsdl = 'http://api.tbotechnology.in/HotelAPI_V7/HotelService.svc?wsdl';

    //Actions
    var $ActionHotelSearch = "http://TekTravel/HotelBookingApi/HotelSearch";

    //NS
    var $NS = "http://TekTravel/HotelBookingApi";

    //TO
    var $ToHotelSearch = "http://api.tbotechnology.in/HotelAPI_V7/HotelService.svc";

    public function testSearch()
    {

        $client = new SoapClient(public_path('\assets\file\TBO.wsdl'), array('soap_version' => SOAP_1_2, 'trace' => 1, "exceptions" => 0));


        $HeaderVar = new SoapVar($this->HeaderXML, XSD_ANYXML, null, null, null);

        $Headers[] = new SoapHeader($this->NS, "Credentials", $this->Credentials,false);
        $Headers[] = new SoapHeader($this->NS, "Action", $this->ActionHotelSearch);
        $Headers[] = new SoapHeader($this->NS, "To", $this->ToHotelSearch);

        $client->__setSoapHeaders($Headers);
        $result = $client->__soapCall('CountryList', []);


    }

有一个名为 https://github.com/BeSimple/BeSimpleSoap 的程序包,但是没有任何文档. 非常感谢您的帮助

There's a package called https://github.com/BeSimple/BeSimpleSoap but there are no any documentation for that. many thanks for the help

推荐答案

仅使用php soap客户端无法实现.

This is not possible to achieve only using php soap client.

这篇关于php soap client如何更改名称空间前缀?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆