php - 如何在 php soap 中调用 sap soap wsdl?
问题描述
PHP / 肥皂
$client = new SoapClient('http://xxx.xxx.xxx.xx:xx/Sap/.../sap-client?wsdl');
$authentication = array(
'login' => '*****',
'password' => '*****'
);
$params = array(
"auth" => $authentication
);
$users = $client->Func1($params);
var_dump($users);
for ($i = 0, $count = count($users->s1); $i < $count; $i++) {
echo "No:" . $users->s1[$i]->no . "<br/>\n";
echo "Name:" . $users->s1[$i]->name . "<br/>\n";
}
SAP / 肥皂
<xsd:import namespace="urn:sap-com:document:sap:rfc:functions"/>
<xsd:complexType name="s1">
<xsd:sequence>
<xsd:element name="no" type="n0:numeric8"/>
<xsd:element name="name" type="n0:char40"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="t2">
<xsd:sequence>
<xsd:element name="item" type="tns:s1" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="Func1">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Tbl" type="tns:t2"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Func1Response">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Tbl" type="tns:t2"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
嗨,我想用 php /soap 调用 sap wsdl。但我在执行后出现“SOAP-ERROR:Encoding: object has no 'Tbl' property”错误。现在,我出现“PHP 致命错误:SOAP-ERROR: Parsing WSDL: Couldn't load from 'url' failed to load external”的错误。我无法修复我的错误。有人能帮我吗?提前致谢!
解决方案
If you want to easily call this SOAP WS with PHP, I strongly recommend you to use a WSDL to PHP generator as it'll ease the request construction and the request handling all using an OOP approach wich is always better.
In addition, using a good IDE adapted to PHP such as PhpStorm or Eclise PDT is the minimum requirement to easily use the generated PHP SDK thanks to autocompletion.
I would advise you to try the PackageGenerator project which is pretty complete and it uses composer.
推荐阅读
- xamarin - 使用 Xamarin Forms 的可用 wifi 连接列表
- python - 如何在 Django 表单中使用自定义值填充/填充 ChoiceField
- node.js - 如果第一个服务端点根据状态码忙,则回退到另一个服务端点
- firebase - Firebase 客户端错误:自定义令牌对应于不同的受众
- django - Recombee 批处理不发送所有数据
- php - NGINX 默认站点工作,但另一个端口上的一个不工作
- java - 如何正确访问 ArrayList 以在 HashMap Java 中进行迭代?
- tensorflow.js - 如何定义具有数千个可能分类值的输入张量?
- java - 套接字连接程序(TCP/IP)适用于 localhost/common 网络但不适用于其他 IP
- android - 如何使用过时的 android sdk 版本