Skip to content

Instantly share code, notes, and snippets.

@bogomolov-dev
Created March 22, 2014 07:10
Show Gist options
  • Save bogomolov-dev/9702508 to your computer and use it in GitHub Desktop.
Save bogomolov-dev/9702508 to your computer and use it in GitHub Desktop.
SOAP Service mit einem SOAP Client in PHP nutzen - http://www.starstormdesign.de/soap-service-mit-einem-soap-client-php-nutzen/
"require": {
[...]
"besimple/soap": "0.2.*"
}
object(stdClass)[7]
public 'details' =>
object(stdClass)[6]
public 'bezeichnung' => string 'Hamburger Bank von 1861 Volksbank' (length=33)
public 'bic' => string 'GENODEF1HH2' (length=11)
public 'ort' => string 'Hamburg' (length=7)
public 'plz' => string '20019' (length=5)
<xsd:complexType name="getBankType">
<xsd:sequence>
<xsd:element name="blz" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<?php
require_once '../../vendor/autoload.php';
$wsdl = 'http://www.thomas-bayer.com/axis2/services/BLZService?wsdl';
$soapClient = new \BeSimple\SoapClient\SoapClient($wsdl);
$bank = new stdClass();
$bank->blz = '20190003';
var_dump($soapClient->getBank($bank));
array (size=2)
0 => string 'getBankResponseType getBank(getBankType $parameters)' (length=52)
<?php
require_once '../../vendor/autoload.php';
$wsdl = 'http://www.thomas-bayer.com/axis2/services/BLZService?wsdl';
$soapClient = new \BeSimple\SoapClient\SoapClient($wsdl);
var_dump($soapClient->__getFunctions());
object(Ssd\SoapExample\GetBankResponseType)[7]
protected 'details' =>
object(Ssd\SoapExample\DetailsType)[6]
protected 'bezeichnung' => string 'Hamburger Bank von 1861 Volksbank' (length=33)
protected 'bic' => string 'GENODEF1HH2' (length=11)
protected 'ort' => string 'Hamburg' (length=7)
protected 'plz' => string '20019' (length=5)
<?php
require_once '../../vendor/autoload.php';
require_once 'GetBankResponseType.php';
require_once 'DetailsType.php';
$wsdl = 'http://www.thomas-bayer.com/axis2/services/BLZService?wsdl';
$options = array(
'classmap' => array(
'getBankResponseType' => 'Ssd\\SoapExample\\GetBankResponseType',
'detailsType' => 'Ssd\\SoapExample\\DetailsType',
),
);
$soapClient = new \BeSimple\SoapClient\SoapClient($wsdl, $options);
<?php
namespace Ssd\SoapExample;
class DetailsType
{
/**
* @var string
*/
protected $bezeichnung;
/**
* @var string
*/
protected $bic;
/**
* @var string
*/
protected $ort;
/**
* @var string
*/
protected $plz;
// Getter und Setter
public function getGoogleSearchLink()
{
return 'http://google.de/q=' . urlencode($this->bezeichnung);
}
}
<?php
namespace Ssd\SoapExample;
class GetBankResponseType
{
/**
* @var \Ssd\SoapExample\DetailsType
*/
protected $details;
// Getter und Setter
}
<xsd:complexType name="getBankResponseType">
<xsd:sequence>
<xsd:element name="details" type="tns:detailsType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="detailsType">
<xsd:sequence>
<xsd:element minOccurs="0" name="bezeichnung" type="xsd:string"/>
<xsd:element minOccurs="0" name="bic" type="xsd:string"/>
<xsd:element minOccurs="0" name="ort" type="xsd:string"/>
<xsd:element minOccurs="0" name="plz" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment