SOAP:整数作为 NULL 传递

发布于 2024-11-04 14:02:48 字数 2323 浏览 4 评论 0原文

在 PHP 文件中,我使用 WSDL 调用我的函数 getCustomerByID(需要一个整数)并传入适当的 ID。问题是,即使将 ID 硬编码到函数中,它仍然会作为 NULL 传递到服务器。

<?php
require_once("./include/nusoap/nusoap.php");
            $client = new SoapClient('D:\wsdl\CustomerService_CustomerServiceSOAPhttpWithIPAddress.wsdl', array('trace' => 1));
            $cId = 100777;
            echo " CID:".$cId;
            echo "<br>";
            try{
                $customerID = $client->getCustomerById(100777);  //Error is here.
                throw new SoapFault('code', 'string', 'actor', 'detail', 'name', 'header');
            }
            catch (Exception $ex) {
            var_dump($ex->faultcode, $ex->faultstring, $ex->faultactor, $ex->detail, $ex->_name, $ex->headerfault);
            }
?>

以下是上面的 try/catch 中吐出的内容:

string 'm:Server' (length=8)
string 'null' (length=4)
null
object(stdClass)[83]
  public 'getCustomerByIdFault1_getCustomerByIdFault' => string 'null' (length=4)
null
null

这是 WSDL 元素:

<xsd:element name="getCustomerById">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="customerId" nillable="true" type="xsd:int"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>

Any here 是服务器捕获的内容,以及来自服务器的后续回复:

SENT

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://CustomerServices/customerService"><SOAP-ENV:Body><ns1:getCustomerById/></SOAP-ENV:Body></SOAP-ENV:Envelope>

您会注意到 不包含任何值。

回复

m:Server<详细信息><服务:getCustomerByIdFault1_getCustomerByIdFault xmlns:service =“http://CustomerServices/customerService” xmlns:xsi =“http://www.w3.org/2001/XMLSchema-instance” xsi:nil =“true”>>

非常感谢任何想法/建议!

From a PHP file, I'm using a WSDL to call my function, getCustomerByID (which expects an integer) and pass in the appropriate ID. Problem is, even when hard coding the ID into the function, it still gets passed to the server as a NULL.

<?php
require_once("./include/nusoap/nusoap.php");
            $client = new SoapClient('D:\wsdl\CustomerService_CustomerServiceSOAPhttpWithIPAddress.wsdl', array('trace' => 1));
            $cId = 100777;
            echo " CID:".$cId;
            echo "<br>";
            try{
                $customerID = $client->getCustomerById(100777);  //Error is here.
                throw new SoapFault('code', 'string', 'actor', 'detail', 'name', 'header');
            }
            catch (Exception $ex) {
            var_dump($ex->faultcode, $ex->faultstring, $ex->faultactor, $ex->detail, $ex->_name, $ex->headerfault);
            }
?>

Here is what is spit out from the try/catch above:

string 'm:Server' (length=8)
string 'null' (length=4)
null
object(stdClass)[83]
  public 'getCustomerByIdFault1_getCustomerByIdFault' => string 'null' (length=4)
null
null

Here is the WSDL element:

<xsd:element name="getCustomerById">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="customerId" nillable="true" type="xsd:int"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>

Any here is what is getting captured by the server, and the subsequent reply from the server:

SENT

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://CustomerServices/customerService"><SOAP-ENV:Body><ns1:getCustomerById/></SOAP-ENV:Body></SOAP-ENV:Envelope>

You'll notice that <ns1:getCustomerById/> doesn't contain any values.

REPLY

<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault xmlns:m="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>m:Server</faultcode><detail><service:getCustomerByIdFault1_getCustomerByIdFault xmlns:service="http://CustomerServices/customerService" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"></service:getCustomerByIdFault1_getCustomerByIdFault></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>

Any thoughts/advice is greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乱了心跳 2024-11-11 14:02:48

你不应该这样称呼它:

$client->call('getCustomerById', array('customerId' => 100777))

Shouldn't you call it like:

$client->call('getCustomerById', array('customerId' => 100777))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文