首页 > 解决方案 > 如何在 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”的错误。我无法修复我的错误。有人能帮我吗?提前致谢!

标签: phpsoapwsdl

解决方案


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.


推荐阅读