vb.net消耗nusoap错误

时间:2015-10-13 14:33:31

标签: mysql vb.net wsdl nusoap

我正在为我的vb.net应用程序构建一个nusoap api - 目前我正在尝试向我的客户端发送许多行的mysql数据,所以我构建了它。

当我尝试在Vb.net中使用它时,我得到了经典:

  

... msdiscocodegenerator无法导入绑定...无法导入绑定...来自命名空间

更多信息:错误状态:

  

自定义工具错误:无法导入WebService / Schema。无法从命名空间'urn:Testing_Service'导入绑定'Testing_ServiceBinding'。无法导入操作'GetData'。缺少数据类型“urn:Testing_Service:return_array_php”。

显然我的代码在VS不喜欢的地方有错误。除了一些骆驼套管外,WSDL检查员都说得好。

为什么我会收到该错误

require_once('lib/nusoap.php'); // basic include.. must go at the top


$SERVICE_NAMESPACE = "urn:Testing_Service"; // create a namespace to run under.

$server = new soap_server(); // the soap object from the include above.

// this has many input parameters but we only need two: the service name and the namespace
$server->configureWSDL('Testing_Service', $SERVICE_NAMESPACE);  

////////////////////////
//                    //
//    Mysql  Test     //
//                    //
////////////////////////

$server->wsdl->addComplexType(
'dataArray',    // MySoapObjectArray
'complexType', 'array', '', 'SOAP-ENC:Array',
array(),
array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:return_array_php[]')), 'tns:return_array_php'
);

$server->register(
'GetData',     
array(), 
array('return'=>'tns:dataArray'),
$namespace,
false,
'rpc',
'encoded',
'mysql test data'
);


function GetData()
{

$servername = "localhost";
$username = "user";
$password = "password";

try {
$conn = new PDO("mysql:host=$servername;dbname=EMRFTD", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
//  echo "Connected successfully"; 
}
catch(PDOException $e)
{
//  echo "Connection failed: " . $e->getMessage();
}
    //already connected to pdo

            // select statement.
            $sql = $conn->prepare("SELECT c.RID AS RID, c.Utype AS Utype, c.Curgency as Curgency, firstname, lastname, putime, slocname, slocadd, sloccity, slocstate, Scene, Dest, dlocname, dlocadd, dloccity, dlocstate, s.fid AS sfid, s.name AS sname, s.faddress AS sfaddress, s.fcity AS sfcity, s.fstate AS sfstate, s.fcontnumb AS sfcontnumb, s.fcontname AS sfcontname, s.fcontract AS sfcontract, d.fid AS dfid, d.name AS dname, d.faddress AS dfaddress, d.fcity AS dfcity, d.fstate AS dfstate, d.fcontnumb AS dfcontnumb, d.fcontname AS dfcontname, d.fcontract AS dfcontract FROM calls c LEFT JOIN patients p ON c.Pnumb = p.pid LEFT JOIN facilities s ON c.Scene = s.fid LEFT JOIN facilities d ON c.Dest = d.fid WHERE 1 ORDER BY :orderby asc");
            $sql->execute(array(':orderby' => "putime")); //leaving this so we can change the order programatically later
            $results = $sql->fetchAll();
$counts = 0;
if ( count($results) ) {
foreach($results as $row) {
    $result[$counts] = array(
        "RID"  => $row['RID'],
        "Utype"   => $row['Utype'],
        "Curgency"    => $row['Curgency']
    );

$counts = $counts+1;
}
} else {
            $result = null;
}
return $result;
}
//process request.
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA); 

整个mysql事务很有效,包括将数据放入数组中 - 执行vardump显示:

  

array(2){[0] => array(3){[“RID”] => string(4)“4117”[“Utype”] => string(13)“ALS Ambulance”[“Curgency”] => string(1)“1”} [1] => array(3){[“RID”] => string(4)“4118”[“Utype”] => string(13)“BLS Ambulance”[“Curgency”] => string(1)“1”}}

为什么VS不会消耗这个?

1 个答案:

答案 0 :(得分:1)

我发现我遇到的错误是缺少数组定义 - 我更改了复杂类型语句以包含两个定义:

  $server->wsdl->addComplexType(
'DataArr', // the type's name
'complexType', // yes.. indeed it is a complex type.
'struct', // php it's a structure. (only other option is array) 
'all', // compositor.. 
'',// no restriction
array(
    'RID' => array('name'=>'RID','type'=>'xsd:string'),
    'Utype' => array('name'=>'Utype','type'=>'xsd:string'),
    'Curgency' => array('name'=>'Curgency','type'=>'xsd:string')
)// the elements of the structure.
);



// Here we need to make another complex type of our last complex type.. but now an array!
$server->wsdl->addComplexType(
'dataArray',//glorious name
'complexType',// not a simpletype for sure!
'array',// oh we are an array now!
'',// bah. blank
'SOAP-ENC:Array',
array(),// our element is an array.
 array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:DataArr[]')),//the attributes of our array.
'tns:DataArr'// what type of array is this?  Oh it's an array of mytable data
);

希望这可以帮助将来遇到类似错误的人