C# PHP客户端和windows服务之间的SOAP通信导致NullReferenceException

C# PHP客户端和windows服务之间的SOAP通信导致NullReferenceException,c#,php,.net,soap,C#,Php,.net,Soap,如果我用SoapUi测试服务,操作会成功,但是如果用PHP实现Soap客户机,参数总是emty,我会得到一个NullReferenceException <?php $options = array(); $options['classmap']['Abonnent'] = 'RequestType'; $client = new SoapClient('wsdllink',$options); class RequestType { public $Email; pu

如果我用SoapUi测试服务,操作会成功,但是如果用PHP实现Soap客户机,参数总是emty,我会得到一个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\u dump($client->\u\u getTypes())

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

电子邮件
姓氏
紫苏
名字

比较SoapUI和PHP的SoapClient发送的消息,例如使用。如果我没记错的话,您必须将PHP发送的XML正文包装在以适当的SOAPAction命名的根元素中

大概是这样的:

class AbonnierenRequest
{
    public $Abbonent;   
}

class Abonnent
{
    public $Email;
    public $Nachname;
    public $Passwort;
    public $Vorname;
}

$request = new AbonnierenRequest();
$request->Abonnent = new Abonnent();

$request->Abonnent->Email = 'email';
$request->Abonnent->Nachname = 'lastname';
$request->Abonnent->Passwort = 'passwort';
$request->Abonnent->Vorname = 'firstname';

$result = $client->Abonnieren($request);

您好,谢谢我跟踪了这两个xml,soupui一个可以工作,但是php客户端xml不能。但是我没有看到错误。好的,如果我用它包装参数,但是如何实现呢?@user2393454请参见编辑。我认为您必须有一个包装
Abonnent
对象。$result=$client->abonneren(数组('Abonnent'=>abo));这个终于可以用了,谢谢
 <?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>
class AbonnierenRequest
{
    public $Abbonent;   
}

class Abonnent
{
    public $Email;
    public $Nachname;
    public $Passwort;
    public $Vorname;
}

$request = new AbonnierenRequest();
$request->Abonnent = new Abonnent();

$request->Abonnent->Email = 'email';
$request->Abonnent->Nachname = 'lastname';
$request->Abonnent->Passwort = 'passwort';
$request->Abonnent->Vorname = 'firstname';

$result = $client->Abonnieren($request);