我正在尝试使用php nusoap创建一个客户端soap调用,以在包含complexTypes的.NET上构建现有的SOAP服务器。
我想调用QueryTestCategory(见下文)
它有param searchTag和Call_Result,它们是字符串
但是param LGI是LoginInfo的类型(struct LoginInfo {string User_Name; string Password;})
那么,我如何设置QueryTestCategory的参数?
我执行getTypes我收到以下
struct HelloWorld { }
struct HelloWorldResponse { string HelloWorldResult; }
struct QueryTestSuite { LoginInfo LGI; string searchTag; string Call_Result; }
struct LoginInfo { string User_Name; string Password; }
struct QueryTestSuiteResponse { ArrayOfSuiteInfo QueryTestSuiteResult; string Call_Result; }
struct ArrayOfSuiteInfo { SuiteInfo SuiteInfo; }
struct SuiteInfo { string Test_Suite_ID; string Test_Suite_Name; string Tag; string Owner; string Remark; }
struct QueryTestCategory { LoginInfo LGI; string searchTag; string Call_Result; }
struct QueryTestCategoryResponse { ArrayOfCategoryInfo QueryTestCategoryResult; string Call_Result; }
struct ArrayOfCategoryInfo { CategoryInfo CategoryInfo; }
struct CategoryInfo { string Test_Category_ID; string Test_Category_Name; string Tag; string Owner; string Remark; }
struct QueryTestCase { LoginInfo LGI; string searchTag; string Call_Result; }
struct QueryTestCaseResponse { ArrayOfTestCaseInfo QueryTestCaseResult; string Call_Result; }
struct ArrayOfTestCaseInfo { TestCaseInfo TestCaseInfo; }
struct TestCaseInfo { string Test_Case_ID; string Test_Case_Name; string Test_Case_Version; string Tag; string Entry_Point; string Test_Kit_Name; string Test_Kit_Version; string Extra_Parameter; string Estimate_Time; string Function_Team; string Remark; string Test_Log_Parser_Name; string Test_Log_Parser_Version; string Test_Log_Parser_Entry_Point; string Test_Log_Parser_Extra_Parameter; string Owner; }
struct QueryTestResult { LoginInfo LGI; string TaskID; string Call_Result; }
struct QueryTestResultResponse { string QueryTestResultResult; string Call_Result; }
我试试这个,但它失败了
/*
* $Id: wsdlclient1.php,v 1.3 2007/11/06 14:48:48 snichol Exp $
*
* WSDL client sample.
*
* Service: WSDL
* Payload: document/literal
* Transport: http
* Authentication: none
*/
require_once('lib/nusoap.php');
$proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : '';
$proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : '';
$proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : '';
$proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : '';
$client = new nusoap_client('http://www.example.com/Query.asmx?WSDL', 'wsdl',
$proxyhost, $proxyport, $proxyusername, $proxypassword);
$err = $client->getError();
if ($err) {
echo "Constructor error";
}
// Doc/lit parameters get wrapped
$param = array('User_Name' => 'SSD_WS_01', 'Password' => 'SSD_WS_01', 'searchTag' => 'test', 'Call_Result' => '');
$result = $client->call('QueryTestCategory', array('parameter' => $param), '', '', false, true);
// Check for a fault
if ($client->fault) {
print_r($result);
} else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error
echo 'Error;
} else {
// Display the result
echo 'Result';
print_r($result);
}
}
阅读此网页后的许多其他信息
http://gznofeng.iteye.com/blog/951762
我的最终代码如下所示
总结......
创建$ param1 = new stdClass,通过$ param1->设置参数varName ='something'
那一切!
23 // Doc/lit parameters get wrapped
24 //$param1 = array('User_Name' => 'SSD_WS_01', 'Password' => 'SSD_WS_01');
25 $param1 = new stdClass();
26 $param1->User_Name = 'SSD_WS_01';
27 $param1->Password = 'SSD_WS_01';
28
29 $result = $client->call('QueryTestCategory', array('LGI' => $param1, 'searchTag' => '' ), '', '', false, true);
30 // Check for a fault
31 if ($client->fault) {
32 echo '<h2>Fault</h2><pre>';
33 print_r($result);
34 echo '</pre>';
35 } else {
36 // Check for errors
37 $err = $client->getError();
38 if ($err) {
39 // Display the error
40 echo '<h2>Error</h2><pre>' . $err . '</pre>';
41 } else {
42 // Display the result
43 echo '<h2>WoW,Result</h2><pre>';
44 print_r($result);
45 echo '</pre>';
46 }
47 }