mysql - vb.net 消费nusoap报错

标签 mysql vb.net wsdl nusoap

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

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

...msdiscocodegenerator failed unable to import binding... Unable to import binding... from namespace

更多信息:错误状态:

Custom tool error: Unable to import WebService/Schema. Unable to import binding 'Testing_ServiceBinding' from namespace 'urn:Testing_Service'. Unable to import operation 'GetData'. The datatype 'urn:Testing_Service:return_array_php' is missing.

显然,我的代码中有一个 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 不消费这个?

最佳答案

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

  $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
);

希望这对以后遇到类似错误的其他人有帮助

关于mysql - vb.net 消费nusoap报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33105423/

相关文章:

asp.net - asmx wsdl 永远加载

javascript - 我可以在任何浏览器上禁用 SOP(同源策略)进行开发吗?

javascript - 使用带有 Node.js 的 REST api 服务器连接到我的 sql 数据库时出现问题

MySQL按日期分组,不存在则强制返回空值

Mysql选择唯一值

vb.net - 隐藏左列DataGridView

c# - 使用 ORM 创建数据库

mysql - 如何从 Mysql 将图像显示到 Devexpress GridView/Devexpress Card View

php - 以不同方式处理 WSDL 文件的独立服务器

mysql - InnoDB 事务 : Lock wait timeout