Php 如何在Yii中制作webservice SOAP 1.2

Php 如何在Yii中制作webservice SOAP 1.2,php,web-services,soap,yii,Php,Web Services,Soap,Yii,问题: <?php class ABFolioController extends CController { public function actions() { return array( 'folio'=>array( 'class'=>'CWebServiceAction', 'serviceOptions'=>array('soapVersi

问题:

<?php
class ABFolioController extends CController
{
    public function actions()
    {
        return array(
            'folio'=>array(
                'class'=>'CWebServiceAction',
                'serviceOptions'=>array('soapVersion'=>'1.2')
            ),
        );

    }

    /**
     * @param  string folioId
     * @param  string cNumber
     * @param  string oDRS
     * @param  string dlr
     * @param  string feeAmount
     * @param  string transactionStatus
     * @param  string captureId
     * @param  datetime captureTimestamp
     * @param  string prefix
     * @param  string oDEFRS
     * @return string the statement
     * @soap
     */
    public function sendFolio($folioId, $cNumber, $oDRS, $dlr,
            $feeAmount, $transactionStatus, $captureId, $captureTimestamp, 
            $prefix, $oDEFRS)
    {
    //

      $model = new Dlfolio();
      $model->folioId = $folioId;
      $model->cNumber = $cNumber;
      $model->oDRS = $oDRS;
      $model->dlr = $dlr;
      $model->feeAmount = $feeAmount;
      $model->transactionStatus = $transactionStatus;
      $model->captureId = $captureId;
      $model->captureTimestamp = $captureTimestamp;
      $model->prefix = $prefix;
      $model->oDEFRS = $oDEFRS;
      $yesno = $model->save();

      if ($yesno=TRUE)
      {
          //on success
          return 'Record Saved';
      }
      else
      {
          //on failure
          return $yesno;
      }

    }   
}
我不知道Yii希望我如何更改soap版本。我正在关注这个。web服务可以工作,但它不是SOAP1.2

班级:

<?php
class ABFolioController extends CController
{
    public function actions()
    {
        return array(
            'folio'=>array(
                'class'=>'CWebServiceAction',
                'serviceOptions'=>array('soapVersion'=>'1.2')
            ),
        );

    }

    /**
     * @param  string folioId
     * @param  string cNumber
     * @param  string oDRS
     * @param  string dlr
     * @param  string feeAmount
     * @param  string transactionStatus
     * @param  string captureId
     * @param  datetime captureTimestamp
     * @param  string prefix
     * @param  string oDEFRS
     * @return string the statement
     * @soap
     */
    public function sendFolio($folioId, $cNumber, $oDRS, $dlr,
            $feeAmount, $transactionStatus, $captureId, $captureTimestamp, 
            $prefix, $oDEFRS)
    {
    //

      $model = new Dlfolio();
      $model->folioId = $folioId;
      $model->cNumber = $cNumber;
      $model->oDRS = $oDRS;
      $model->dlr = $dlr;
      $model->feeAmount = $feeAmount;
      $model->transactionStatus = $transactionStatus;
      $model->captureId = $captureId;
      $model->captureTimestamp = $captureTimestamp;
      $model->prefix = $prefix;
      $model->oDEFRS = $oDEFRS;
      $yesno = $model->save();

      if ($yesno=TRUE)
      {
          //on success
          return 'Record Saved';
      }
      else
      {
          //on failure
          return $yesno;
      }

    }   
}

当我将客户端设置为v1.2时,我总是从服务器接收v1.2响应,当我将客户端设置为v1.1时,我总是从服务器接收v1.1响应,也许它会自动检测客户端版本并用它覆盖服务器版本

$client=new SoapClient('http://hys.local/ABFolio/folio',array('soap_version'=>SOAP_1_2,'trace'=>true));
var_dump($client);
echo $client->sendFolio();
echo $client->__getLastRequest();
echo $client->__getLastResponse();
答复是1.2

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"
答复是1.1

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
如果我检查此代码,我看不到您的代码中有任何错误

编辑:

好的,这个怎么样
framework\web\services\CWsdlGenerator.php

/**
 * @return array options for creating SoapServer instance
 * @see http://www.php.net/manual/en/function.soap-soapserver-construct.php
 */
protected function getOptions()
{
    $options=array();
    if($this->soapVersion==='1.1')
        $options['soap_version']=SOAP_1_1;
    else if($this->soapVersion==='1.2')
        $options['soap_version']=SOAP_1_2;
    if($this->actor!==null)
        $options['actor']=$this->actor;
    $options['encoding']=$this->encoding;
    foreach($this->classMap as $type=>$className)
    {
        $className=Yii::import($className,true);
        if(is_int($type))
            $type=$className;
        $options['classmap'][$type]=$className;
    }
    return $options;
}
/*
 * @param DOMDocument $dom Represents an entire HTML or XML document; serves as the root of the document tree
 */
private function addBindings($dom)
{
    $binding=$dom->createElement('wsdl:binding');
    $binding->setAttribute('name',$this->serviceName.'Binding');
    $binding->setAttribute('type','tns:'.$this->serviceName.'PortType');

    $soapBinding=$dom->createElement('soap:binding');
    $soapBinding->setAttribute('style','rpc');
    $soapBinding->setAttribute('transport','http://schemas.xmlsoap.org/soap/http');
    $binding->appendChild($soapBinding);

    $dom->documentElement->appendChild($binding);

    foreach($this->_operations as $name=>$doc)
        $binding->appendChild($this->createOperationElement($dom,$name));
}
正如我所见,传输是预定义的(您可以检查并将其替换为12)

我的wsdl在添加12之后变成这样

<wsdl:binding name="ABFolioControllerBinding" type="tns:ABFolioControllerPortType">    
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap12/http"/>
</wsdl:binding>
这就是为什么我认为一切都是正确的

编辑:

这是decesion,你需要

xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 

内部
当我将客户端设置为v1.2时,我总是从服务器接收v1.2响应,当我将客户端设置为v1.1时,我总是从服务器接收v1.1响应,也许它会自动检测客户端版本并用它覆盖服务器版本

$client=new SoapClient('http://hys.local/ABFolio/folio',array('soap_version'=>SOAP_1_2,'trace'=>true));
var_dump($client);
echo $client->sendFolio();
echo $client->__getLastRequest();
echo $client->__getLastResponse();
答复是1.2

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"
答复是1.1

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
如果我检查此代码,我看不到您的代码中有任何错误

编辑:

好的,这个怎么样
framework\web\services\CWsdlGenerator.php

/**
 * @return array options for creating SoapServer instance
 * @see http://www.php.net/manual/en/function.soap-soapserver-construct.php
 */
protected function getOptions()
{
    $options=array();
    if($this->soapVersion==='1.1')
        $options['soap_version']=SOAP_1_1;
    else if($this->soapVersion==='1.2')
        $options['soap_version']=SOAP_1_2;
    if($this->actor!==null)
        $options['actor']=$this->actor;
    $options['encoding']=$this->encoding;
    foreach($this->classMap as $type=>$className)
    {
        $className=Yii::import($className,true);
        if(is_int($type))
            $type=$className;
        $options['classmap'][$type]=$className;
    }
    return $options;
}
/*
 * @param DOMDocument $dom Represents an entire HTML or XML document; serves as the root of the document tree
 */
private function addBindings($dom)
{
    $binding=$dom->createElement('wsdl:binding');
    $binding->setAttribute('name',$this->serviceName.'Binding');
    $binding->setAttribute('type','tns:'.$this->serviceName.'PortType');

    $soapBinding=$dom->createElement('soap:binding');
    $soapBinding->setAttribute('style','rpc');
    $soapBinding->setAttribute('transport','http://schemas.xmlsoap.org/soap/http');
    $binding->appendChild($soapBinding);

    $dom->documentElement->appendChild($binding);

    foreach($this->_operations as $name=>$doc)
        $binding->appendChild($this->createOperationElement($dom,$name));
}
正如我所见,传输是预定义的(您可以检查并将其替换为12)

我的wsdl在添加12之后变成这样

<wsdl:binding name="ABFolioControllerBinding" type="tns:ABFolioControllerPortType">    
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap12/http"/>
</wsdl:binding>
这就是为什么我认为一切都是正确的

编辑:

这是decesion,你需要

xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 

内部
当我将客户端设置为v1.2时,我总是从服务器接收v1.2响应,当我将客户端设置为v1.1时,我总是从服务器接收v1.1响应,可能它会自动检测客户端版本并用它覆盖服务器版本?我使用soapUI进行测试。它会告诉您是1.1还是1.2,因为它读取wsdl上的传输类型。这让您知道这是一个soap 1.1服务当我将客户端设置为v1.2时,我总是从服务器接收v1.2响应,当我将客户端设置为v1.1时,我总是从服务器接收v1.1响应,也许它会自动检测客户端版本并用它覆盖服务器版本?我使用soapUI进行测试。它将告诉您是1.1还是1.2,因为它读取wsdl上的传输类型。这让您知道这是一个soap 1.1服务这是关于如何在Yii框架中调用它。不是普通的php。谢谢您的回复。您认为我使用什么样的soap服务器?不是php默认值?我只是说,也许php服务器版本总是被客户端版本LAMERR覆盖,这是一个特定于框架的问题。有一个类对此具有特定属性。我显然错误地调用了该属性,并且想知道在框架内执行该操作的正确方法。我知道如何使用php soapClient。这不是我的问题。如果我想在没有框架的情况下使用它,我会的,但这不是我的问题。我知道这是一个特定于框架的问题,但是你如何确定你的soap版本设置不正确?我不知道传输是否正确,也许它一定是其他问题。这是关于如何在Yii框架中调用它。不是普通的php。谢谢您的回复。您认为我使用什么样的soap服务器?不是php默认值?我只是说,也许php服务器版本总是被客户端版本LAMERR覆盖,这是一个特定于框架的问题。有一个类对此具有特定属性。我显然错误地调用了该属性,并且想知道在框架内执行该操作的正确方法。我知道如何使用php soapClient。这不是我的问题。如果我想在没有框架的情况下使用它,我会这样做,但这不是我的问题。我知道这是一个特定于框架的问题,但是您如何确定您的soap版本设置不正确?我不知道传输是否正确,可能是其他原因