简体   繁体   中英

How to call sap soap wsdl in php soap?

PHP / SOAP

$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 / SOAP

<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>

Hi, I want to call sap wsdl with php /soap. But I took an "SOAP-ERROR:Encoding: object has no 'Tbl' property" error after execution of it. Now, I am taking error of "PHP fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'url' failed to load external".I couldn't fix my error. Can someone help me? Thanks in advance!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM