使用javascript而不是php访问Web服务器


Access the webserver by using javascript instead of php

我现在正在使用phonegap开发一个应用程序。我在这里找到了一个类似的php代码,可以评估到本地服务器,但不幸的是phonegap不支持php。

有人能帮我把下面的php代码"翻译"成JQueryajax或任何其他javascript代码吗?谢谢

require_once('nusoap.php');
  /* create client */
  $endpoint = "http://www.pascalbotte.be/rcx-ws/rcx";
  $ns = "http://phonedirlux.homeip.net/types";
  $client = new soapclient($endpoint);
  // queryRcx is the name of the method you want to consume
  // RcxQuery_1 is the name of parameter object you have to send
  // x and y are the names of the integers contained in the object
  $result = $client->call('queryRcx',array('RcxQuery_1' => array('x' => 12,'y' => 13)), $ns);
print_r($result);

步骤1。解决与关联的404http://www.pascalbotte.be/rcx-ws-rpc/rcx?WSDL
步骤2。获取一个JavaScriptSOAP客户端
步骤3。... ... ...
步骤4。利润!

说真的。所有这些都需要一个基于JavaScript的SOAP客户端。虽然它们不是一打硬币,但它们很常见。上面的一个是针对jQuery的,但找到其他实现很容易。

WSDL定义导致404的事实可能是问题,也可能不是问题,因为实际的wsdl定义在技术上是可选的,但您确实想弄清楚发生了什么。

您可以将此标头添加到PHP文件或.htaccess中,以避免跨域reqs的问题:标头("访问控制-允许原始:*"(;

将所有(*(替换为您的域;(

祝你好运!