开发者

php soap server "missing out" one argument at server level

I have a soap method called createReport() which has the following arguments:

  • token
  • reportType
  • time
  • content
  • title
  • analystEmail
  • email_template
  • pdfUrl
  • status
  • isActive
  • sector
  • region
  • reportID

My WSDL defines the arguments as such:

 <wsdl:message name="reportRequest">
  <wsdl:part name="token" type="xsd:string"/>
  <wsdl:part name="reportType" type="xsd:int"/>
  <wsdl:part name="time" type="xsd:int"/>
  <wsdl:part name="content" type="xsd:string"/>
  <wsdl:part name="title" type="xsd:string"/>
  <wsdl:part name="analystEmail" type="xsd:string"/>
  <wsdl:part name="email_template" type="xsd:string"/>
  <wsdl:part name="pdfUrl" type="xsd:string"/>
  <wsdl:part name="status" type="xsd:string"/>
 开发者_开发百科 <wsdl:part name="isActive" type="xsd:boolean"/>
  <wsdl:part name="sector" type="xsd:int"/>
  <wsdl:part name="region" type="xsd:int"/>
  <wsdl:part name="reportID" type="xsd:int"/>
</wsdl:message>

I request the response using the default php SOAP client as such:

    $report_id = $client->createReport(
                                    $token,
                                    1,
                                    time(),
                                    'content!',
                                    'Company Report',
                                    'support@website.com',
                                    'email template!',
                                    'pdf URL',
                                    2,
                                    1,
                                    33,
                                    -1,
                                    1
    );

Currently the server is function is set to simply return a list of arguments:

function createReport($token, $reportType, $time, $content, $title, $analystEmail, $email_template, $pdfUrl, $status, $isActive, $sector, $region, $reportID){

//if the user has a bad token
if ( checkToken($token) !== 0 ){
    return checkToken($token);
    $return->success = 0;
    $return->information = "Bad Token ".  checkToken( correctPassword() );
    return $return;
}


$return->information = '\nToken: '.$token . "\nReportType " .$reportType . "\nTime: " . $time . "\nContent: " . $content . "\nTitle: " . $title . "\nEmail: " . $analystEmail . "\nTemplate: " . $email_template . "\nPDF: " . $pdfUrl . "\nStatus: " . $status . "\nisActive: " . $isActive . "\nsector: " . $sector . "\nregion: " .$region . "\nreportID: " . $reportID;
return $return;
}

The generated SOAP request:

    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethods-delayed-quotes" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <SOAP-ENV:Body>
            <ns1:createReport>
                  <token xsi:type="xsd:string">8f4cf7ae4bd4ab02e591c8b0ab72fe57b4f8ad0c</token>
                  <reportType xsi:type="xsd:int">1</reportType>
                  <time xsi:type="xsd:int">1301385965</time>
                  <content xsi:type="xsd:string">content!</content>
                  <title xsi:type="xsd:string">Company Report</title>
                  <analystEmail xsi:type="xsd:string">support@website.com</analystEmail>
                  <email_template xsi:type="xsd:string">email template!</email_template>
                  <pdfUrl xsi:type="xsd:string">pdf URL</pdfUrl>
                  <status xsi:type="xsd:int">2</status>
                  <isActive xsi:type="xsd:boolean">true</isActive>
                  <sector xsi:type="xsd:int">33</sector>
                  <region xsi:type="xsd:int">-1</region>
                  <reportID xsi:type="xsd:int">1</reportID>
            </ns1:createReport>
      </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

And the response:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethods-delayed-quotes" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="http://wood.example.net/master/api/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <SOAP-ENV:Body>
        <ns1:createReportResponse>
            <response xsi:type="ns2:ReportInfo">
                <information xsi:type="xsd:string">\nToken: 8f4cf7ae4bd4ab02e591c8b0ab72fe57b4f8ad0cReportType 1Time: content!Content: Company ReportTitle: support@website.comEmail: email template!Template: pdf URLPDF: 2Status: 1isActive: 33sector: -1region: 1reportID: </information>
                </response>
            </ns1:createReportResponse>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

Notice the result string:

Token: 8f4cf7ae4bd4ab02e591c8b0ab72fe57b4f8ad0c
ReportType 1
Time: content!
Content: Company Report
Title: support@website.com
Email: email template!
Template: pdf URL
PDF: 2
Status: 1
isActive: 33
sector: -1
region: 1
reportID:

time = "content!"? How is that happening? It seems that the time Element is being skipped or spliced... Is there a SOAP-valid (especially client-side) workaround to this?


The answer was to check the var_dump() and then write the correct SOAP request and response manually. This fixed the problem. Thanks to Matt Gibson for the pointer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜