0

我在 PHP 中使用 NuSOAP 并使用 Java 构建的 Web 服务。

当调用 NuSOAP 时,我传递了这个参数:

$args[]=array('name'=>'content', 'value'=>base64_encode($content), 'type'=>'Base64Binary');

但是,在检查 SOAPXML 时,我看到以下内容:

<content xsi:type="xsd:string">PD94bWwgdmVywIiBlbmNvZ....cmQ+DQoNCg==</content>
                  Note:^^^^^^

在 nusoap.php 中,我看到以下内容:

/*
$Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $

NuSOAP - Web Services Toolkit for PHP
...
*/
...
    /**
    * XML Schema types in an array of uri => (array of xml type => php type)
    * is this legacy yet?
    * no, this is used by the nusoap_xmlschema class to verify type => namespace mappings.
    * @var      array
    * @access   public
    */
    var $typemap = array(
    'http://www.w3.org/2001/XMLSchema' => array(
        'string'=>'string','boolean'=>'boolean',...,'base64Binary'=>'string', ...),
    'http://www.w3.org/2000/10/XMLSchema' => array(...,'base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
    'http://www.w3.org/1999/XMLSchema' => array(...,'base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
    'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'),
    'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'),
    'http://xml.apache.org/xml-soap' => array('Map')
    );

请注意,在所有情况下,

'base64Binary'=>'string'

这可能就是我面临这个错误的原因!为什么会发生这种类型转换,我可以安全地修改此文件并执行以下操作:

'base64Binary'=>'base64Binary'
4

1 回答 1

0

php base64_encode 功能返回一个字符串。所以 nusoap 正在正确读取类型。尝试引用内容而不先对其进行编码。

$args[]=array('name'=>'content', 'value'=>$content, 'type'=>'Base64Binary');

C。

于 2010-11-16T13:22:16.950 回答