使用soapClient时发生SOAP操作错误


SOAP action error when using soapClient

我在尝试进行soap调用时遇到此错误。

The SOAP action specified on the message, '', does not match the HTTP SOAP Action. 

当我调用$service->SearchTouristItems($sti);(这个函数在下面)时,我得到了上面的错误,我不知道为什么。

下面是我正在使用的代码。

//我用过http://www.urdalen.no/wsdl2php/创建扩展SoapClient 的TCS2Service

$service = new TCS2Service() ;
$sd = new ServiceDescriptor;
$sd->UniqueIdentifier = 'xxxxxxxxx-xxxxx-xxxx-xxxxx-xxxxxx';
$stic = new SearchTouristItemCriteria;
$stic->SearchString = array ('dublin') ;    
$sti = new SearchTouristItems;
$sti->searchTouristItemCriteria = $sd;
$sti->serviceDescriptor = $stic;
$result = $service->SearchTouristItems($sti);
    echo "<pre>";
    print_r($result);
    echo "</pre>";

SearchTouristItems looks like this  
  /**
   *  
   *
   * @param SearchTouristItems $parameters
   * @return SearchTouristItemsResponse
   */
  public function SearchTouristItems(SearchTouristItems $parameters) {
    return $this->__soapCall('SearchTouristItems', array($parameters),       array(
            'uri' => 'http://tempuri.org/',
            'soapaction' => ''
           )
      );
  }

这是客户端的初始化

public function TCS2Service($wsdl = "http://www.example.com/services/TCS2Service.svc", $options = array( 'soap_version'  => SOAP_1_2, 
          'exceptions'    => true, 
          'trace'         => 1, 
          'cache_wsdl'    => WSDL_CACHE_NONE,)) {
  foreach(self::$classmap as $key => $value) {
    if(!isset($options['classmap'][$key])) {
      $options['classmap'][$key] = $value;
    }
  }
  parent::__construct($wsdl, $options);
}

虽然不确定,但代码中'soapaction' => ''的值被提供的参数替换了。我没有用PHP调用web服务的经验,所以我只是想了想。

我认为您的ws寻址没有打开。请打开ws-寻址并再次检查。

我会做什么:

  • 检查SOAP操作是否在WSDL中定义良好:查找address location="

  • 尝试另一个WSDL到php的转换器

  • 发送WSDL url,这样我就可以在旁边尝试