PHP SOAP返回SOAP错误:服务器无法使用.asmx Web服务处理请求 [英] PHP SOAP returning SOAP Fault: Server was unable to process request with .asmx Web Service

查看:85
本文介绍了PHP SOAP返回SOAP错误:服务器无法使用.asmx Web服务处理请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难使SOAP请求正常工作,这需要XML字符串作为输入.

I am having difficulty in getting a SOAP request working properly , which requires XML string as input.

正在扔

"SOAP错误:服务器无法处理请求.--->值不能为空.参数名称:s"

无论我发送什么输入,我都使用了nusoap,但无济于事,PHP肥皂库.我使用的代码是:

no matter what input i send , i have used nusoap but to no avail , PHP soap library. The code i am using is:

<?
$aOptions = array(
'location' => 'http://webserviceurl.asmx',
'uri' => 'http://tempuri.org/',
"style" => SOAP_RPC,
"use" => SOAP_ENCODED
);
$client = new SOAPClient(null, $aOptions);

$request ='<item xmlns="rmsItem">
      <columns>
        <column>description</column>
        <column>department</column>
        <column>brand</column>
        <column>lastsold</column>
        <column>lastupdated</column>
        <column>quantityonhand</column>
        <column>weight</column>
      </columns>
      <filters>
        <filter>
          <filterColumn>quantityonhand</filterColumn>
          <operator>greaterthan</operator>
          <filterValue>20</filterValue>
        </filter>
        <filter>
          <filterColumn>lastsold</filterColumn>
          <operator>greaterthan</operator>
          <filterValue>01-01-2005</filterValue>
        </filter>
      </filters>
      <sortColumns>
        <sortColumn>
          <sortColumnName>lastsold</sortColumnName>
          <sortType>ascending</sortType>
        </sortColumn>
        <sortColumn>
          <sortColumnName>quantityonhand</sortColumnName>
          <sortType>descending</sortType>
        </sortColumn>
      </sortColumns>
    </item>';

//$result = $client->__soapCall('getAllInfo',array('infoRequestXml'=>(string)($request),'errorMessage'=>'') ,array('soapaction' => 'http://webserviceurl/getAllInfo'));

$soapvar = new SoapVar($request , XSD_ANYXML);

$params = array("infoRequestXml" => $soapvar);

//print_r($params);
//$result = $this->soapclient->__soapCall("SaveItem", array("parameters"=>$params), null, $this->soapheaders);
try
{
$result=$client->__soapCall('getAllInfo',array("parameters"=>$params),array('soapaction' => 'http://webserviceurl/getAllInfo'));
}
catch (SoapFault $e) {
    echo "SOAP Fault: ".$e->getMessage()."<br />\n";
}
echo "<pre>\n";
echo htmlspecialchars($client->__getLastRequest())."\n";
echo "Response:\n".htmlspecialchars($client->__getLastResponse())."\n";
echo "</pre>"; 

var_dump($result);

?>

最近两天,我把头撞在墙上,在google上搜索了此问题,但没有解决或指导我的答案.

I am banging my head against a wall from last two days, searched google for this problem but got no answer that solves or guide me through.

任何可以对此有所了解的人都将受到高度赞赏.预先感谢.

Anyone who can throw some light on this will be highly appreciated. Thanks in advance.

推荐答案

不要通过SOAPVar运行XML,如果可以的话,请利用Web服务的WSDL选项:

Don't run the XML through SOAPVar, and take advantage of the WSDL option of your web service if you can:

<?php

$client = new SOAPClient(
    'http://webserviceurl.asmx?WSDL',
    array(
        'location' => 'http://webserviceurl.asmx',
        'trace' => 1,
        'style' => SOAP_RPC,
        'use' => SOAP_ENCODED,
    )
);

$request = '<item xmlns="rmsItem">
      <columns>
        <column>description</column>
        <column>department</column>
        <column>brand</column>
        <column>lastsold</column>
        <column>lastupdated</column>
        <column>quantityonhand</column>
        <column>weight</column>
      </columns>
      <filters>
        <filter>
          <filterColumn>quantityonhand</filterColumn>
          <operator>greaterthan</operator>
          <filterValue>20</filterValue>
        </filter>
        <filter>
          <filterColumn>lastsold</filterColumn>
          <operator>greaterthan</operator>
          <filterValue>01-01-2005</filterValue>
        </filter>
      </filters>
      <sortColumns>
        <sortColumn>
          <sortColumnName>lastsold</sortColumnName>
          <sortType>ascending</sortType>
        </sortColumn>
        <sortColumn>
          <sortColumnName>quantityonhand</sortColumnName>
          <sortType>descending</sortType>
        </sortColumn>
      </sortColumns>
    </item>';

$result = array();

$params = array("infoRequestXml" => $request);

try {
    $result = $client->__soapCall('getAllInfo', array("parameters"=>$params));
} catch (SoapFault $e) {
    echo "SOAP Fault: ".$e->getMessage()."<br />\n";
}

echo "<pre>";
echo htmlspecialchars($client->__getLastRequestHeaders())."\n";
echo htmlspecialchars($client->__getLastRequest())."\n";
echo "Response:\n".htmlspecialchars($client->__getLastResponseHeaders())."\n";
echo htmlspecialchars($client->__getLastResponse())."\n";
echo "</pre>"; 

var_dump($result);

?>

这篇关于PHP SOAP返回SOAP错误:服务器无法使用.asmx Web服务处理请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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