SoapUi を使用してサービスをテストすると、操作は成功しますが、PHP を使用して Soap Client を実装すると、パラメーターは常に空になり、NullReferenceException が発生します。
<?php
$options = array();
$options['classmap']['Abonnent'] = 'RequestType';
$client = new SoapClient('wsdllink',$options);
class RequestType
{
public $Email;
public $Nachname;
public $Passwort;
public $Vorname;
}
$abo = new RequestType;
$abo->Email = 'email';
$abo->Nachname = 'lastname';
$abo->Passwort = 'passwort';
$abo->Vorname = 'firstname';
try {
$result = $client->Abonnieren($abo);
} catch(SoapFault $e) {
echo "Request :\n". ($client->__getLastRequest()). "\n";
echo "Response :\n". ($client->__getLastResponseHeaders()). "\n";
echo "Response :\n". ($client->__getLastResponse()). "\n";
echo($e->getMessage());
} catch(Exception $e) {
echo $e->getMessage();
}
?>
var_dump($client->__getFunctions())
array(2) {
[0]=>
string(53) "AbonnierenResponse Abonnieren(Abonnieren $parameters)"
[1]=>
string(53) "RegisterIBResponse RegisterIB(RegisterIB $parameters)"
}
var_dump($client->__getTypes())
array(8) {
[0]=>
string(87) "struct Abonnent {
string Email;
string Nachname;
string Passwort;
string Vorname;
}"
[1]=>
string(41) "struct Abonnieren {
Abonnent abonnent;
}"
[2]=>
string(56) "struct AbonnierenResponse {
boolean AbonnierenResult;
}"
[3]=>
string(41) "struct RegisterIB {
Abonnent abonnent;
}"
[4]=>
string(56) "struct RegisterIBResponse {
boolean RegisterIBResult;
}"
[5]=>
string(8) "int char"
[6]=>
string(17) "duration duration"
[7]=>
string(11) "string guid"
}
SoupUI からの XML
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tem="http://tempuri.org/"
xmlns:prm="http://schemas.datacontract.org/2004/07/PRMarketService">
<soapenv:Header/>
<soapenv:Body>
<tem:Abonnieren>
<tem:abonnent>
<prm:Email>email</prm:Email>
<prm:Nachname>lastname</prm:Nachname>
<prm:Passwort>passwort</prm:Passwort>
<prm:Vorname>firstname</prm:Vorname>
</tem:abonnent>
</tem:Abonnieren>
</soapenv:Body>
</soapenv:Envelope>
PHP クライアントからの XML
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://schemas.datacontract.org/2004/07/PRMarketService"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns2="http://tempuri.org/">
<SOAP-ENV:Body>
<ns2:Abonnieren xsi:type="ns1:Abonnent">
<ns1:Email>email</ns1:Email>
<ns1:Nachname>lastname</ns1:Nachname>
<ns1:Passwort>passwort</ns1:Passwort>
<ns1:Vorname>firstname </ns1:Vorname>
</ns2:Abonnieren>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>