php 肥皂服务器“错过”服务器级别的一个参数
我有一个名为 createReport() 的 SOAP 方法,它具有以下参数:
- token
- reportType
- time
- content
- title
- AnalystEmail
- email_template
- pdfUrl
- status
- isActiveector
- Region
- 我使用默认的 php SOAP 客户端
- reportID
我的 WSDL 定义参数如下:
<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>
请求响应,如下所示:
$report_id = $client->createReport(
$token,
1,
time(),
'content!',
'Company Report',
'[email protected]',
'email template!',
'pdf URL',
2,
1,
33,
-1,
1
);
目前服务器函数设置为仅返回参数列表:
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;
}
生成的 SOAP 请求:
<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">[email protected]</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>
以及响应:
<?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: [email protected]: email template!Template: pdf URLPDF: 2Status: 1isActive: 33sector: -1region: 1reportID: </information>
</response>
</ns1:createReportResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
注意结果字符串:
Token: 8f4cf7ae4bd4ab02e591c8b0ab72fe57b4f8ad0c
ReportType 1
Time: content!
Content: Company Report
Title: [email protected]
Email: email template!
Template: pdf URL
PDF: 2
Status: 1
isActive: 33
sector: -1
region: 1
reportID:
time = "content!"? 这是怎么发生的?似乎 Element 被跳过或拼接的时间...是否有 SOAP 有效的(尤其是客户端)解决方法?
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',
'[email protected]',
'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">[email protected]</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: [email protected]: 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: [email protected]
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案是检查 var_dump(),然后手动编写正确的 SOAP 请求和响应。这解决了问题。感谢马特·吉布森的指点。
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.