肥皂消除我的数据

时间:2014-01-22 10:23:58

标签: php soap

Soap服务器抛出错误,因为我发送了空字段。这是__getLastRequest结果。 CreateDate字段不应为空。

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/"><SOAP-ENV:Body><ns1:PreliminaryApplication><ns1:DopingPreliminaryApplication><ns1:SourceID>1</ns1:SourceID><ns1:FullName>Array</ns1:FullName><ns1:Gsm>Array</ns1:Gsm><ns1:EMail>Array</ns1:EMail><ns1:CampaignID>1</ns1:CampaignID><ns1:DataPackageID>1</ns1:DataPackageID><ns1:VoicePackageID>1</ns1:VoicePackageID><ns1:SpecialProductPackageID>1</ns1:SpecialProductPackageID><ns1:CreateDate/><ns1:Description>Array</ns1:Description></ns1:DopingPreliminaryApplication></ns1:PreliminaryApplication></SOAP-ENV:Body></SOAP-ENV:Envelope>

这是我的要求:

$client->PreliminaryApplication(array(
            'DopingPreliminaryApplication' => 
                array(
                    'SourceID' => array(0 => -1),                                //
                    'FullName' => array(0 => $fullName),
                    'Gsm'      => array(0 => $gsm),
                    'EMail'    => array(0 => $this->input->post('email')),
                    'CampaignID' => array(0 => 1),
                    'DataPackageID' => array(0 => 2),
                    'VoicePackageID' => array(0 => 3),
                    'SpecialProductPackageID' => array(0 => 4),
                    'CreateDate' => array(
                        0 => $date->format('c')
                    ),
                    'Description' => array(
                        0 => 'test'
                    )
                )
        ));

这是服务器需要的xml

<?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Header>
        <AuthHeaderDopingWebService xmlns="http://tempuri.org/">
          <Username>string</Username>
          <Password>string</Password>
        </AuthHeaderDopingWebService>
      </soap:Header>
      <soap:Body>
        <PreliminaryApplication xmlns="http://tempuri.org/">
          <DopingPreliminaryApplication>
            <SourceID>int</SourceID>
            <FullName>string</FullName>
            <Gsm>string</Gsm>
            <EMail>string</EMail>
            <CampaignID>int</CampaignID>
            <DataPackageID>int</DataPackageID>
            <VoicePackageID>int</VoicePackageID>
            <SpecialProductPackageID>int</SpecialProductPackageID>
            <CreateDate>dateTime</CreateDate>
            <Description>string</Description>
          </DopingPreliminaryApplication>
        </PreliminaryApplication>
      </soap:Body>
    </soap:Envelope>

感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

你不需要所有那些阵列。 请尝试以下方法:

try {
    $client     = new SoapClient('http://dcpanel.doping.com.tr/DopingPreliminaryApplicationManagamentService.asmx?WSDL');
    $headerBody = array(
        'AuthHeaderDopingWebService' => array(
            'Username' => 'username',
            'Password' => 'password'
        )
    );
    $header     = new SOAPHeader("http://tempuri.org/", 'AuthHeaderDopingWebService', $headerBody);
    $client->__setSoapHeaders($header);
    $date   = new DateTime('now');
    $result = $client->PreliminaryApplication(
        array(
             'DopingPreliminaryApplication' => (object)array(
                     'SourceID'                => -1,
                     'FullName'                => $fullName,
                     'Gsm'                     => $gsm,
                     'EMail'                   => $this->input->post('email'),
                     'CampaignID'              => 1,
                     'DataPackageID'           => 2,
                     'VoicePackageID'          => 3,
                     'SpecialProductPackageID' => 4,
                     'CreateDate'              => $date->format('c'),
                     'Description'             => 'test'
                 )
        )
    );
    var_dump($result);
} catch (Exception $e) {
    echo "error" . $e->getMessage();
}