如何检查服务器是否能够在运行时处理SOAP请求?我需要在脚本执行之前验证它.
我正在尝试创建一个Web服务,但在此之前,我试图找到一个我在互联网上找到的简单示例,但我不断收到以下错误:
Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in C:\Documents and Settings\geoff\My Documents\Websites\jquery\index.php:20 Stack trace: #0 [internal function]: SoapClient->__call('getStockQuote', Array) #1 C:\Documents and Settings\geoff\My Documents\Websites\jquery\index.php(20): SoapClient->getStockQuote(Array) #2 {main} thrown in C:\Documents and Settings\geoff\My Documents\Websites\jquery\index.php on line 20
Run Code Online (Sandbox Code Playgroud)
我正在使用nusoap v1.94
我的Web服务代码如下所示:
function getStockQuote($symbol) {
$price = '1.23';
return $price;
}
require('nusoap.php');
$server = new soap_server();
$server->configureWSDL('stockserver', 'urn:stockquote');
$server->register("getStockQuote",
array('symbol' => 'xsd:string'),
array('return' => 'xsd:decimal'),
'urn:stockquote',
'urn:stockquote#getStockQuote');
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA)
? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
Run Code Online (Sandbox Code Playgroud)
我知道一个原因是在你的服务器脚本中的php标签之前或之后有空格,但事实并非如此.这让我疯了几个小时!任何帮助将非常感激.
我正在尝试使用服务器端的nusoap为动态站点开发业务逻辑(因为我需要wsdls,PHP SOAP扩展不能生成wsdls),以及客户端的PHP SOAP扩展.
但是,我甚至无法获得登录和getRole功能.当我尝试调用客户端时,我得到以下消息
Uncaught SoapFault exception: [Client] looks like we got no XML document in [some paths]...
Run Code Online (Sandbox Code Playgroud)
Wsdl确实存在于服务器端,而客户端确实读取它(当我为wsdl输入错误的url时,我收到错误).
谁能帮忙?
嗨我正在使用此代码为nusoap服务器,但当我在Web浏览器中调用服务器时,它显示消息"此服务不提供Web描述"这是代码
<?
//call library
require_once ('lib/nusoap.php');
//using soap_server to create server object
$server = new soap_server;
//register a function that works on server
$server->register('hello');
// create the function
function hello($name)
{
if(!$name){
return new soap_fault('Client','','Put your name!');
}
$result = "Hello, ".$name;
return $result;
}
// create HTTP listener
$server->service($HTTP_RAW_POST_DATA);
exit();
?>
Run Code Online (Sandbox Code Playgroud)
帮助......
我开发了一些代码,它使用PHP的NuSoap类来调用soap web服务.我正在使用NuSoap而不是PHP 5本机类,主要是因为我不希望在共享Web服务器上安装此代码时添加额外的先决条件.代码在我的机器上正常工作:
require DOCROOT.'modules/nbn_species_dict_sync/lib/nusoap.php';
$client = new nusoap_client('http://www.nbnws.net/ws_3_5/GatewayWebService?wsdl', true);
$query1 = '<TaxonReportingCategoryListRequest xmlns="http://www.nbnws.net/TaxonReportingCategory" registrationKey="'.$key.'"></TaxonReportingCategoryListRequest>';
$response = $client->call('GetTaxonReportingCategoryList', $query1);
Run Code Online (Sandbox Code Playgroud)
当我把它放在虚拟服务器而不是在本地运行时,最后一行只挂了大约10秒然后PHP炸弹了.没有异常被引发并且没有PHP错误(我已经尝试过使用try..catch和set_error_handler来确定).
我的第一反应是,这可能是在服务器上运行阻止传出请求的防火墙,但我在其他地方成功使用cUrl进行请求,我很确定此处没有运行防火墙.调用$ client-> use_curl对NuSoap调用没有任何影响,但它仍然不起作用.
任何想法为什么会发生这种情况将非常感激.
我正在尝试使用nusoap实现一个简单的Web服务.服务器:
<?php
require_once "nusoaplib/nusoap.php";
class food {
public function getFood($type) {
switch ($type) {
case 'starter':
return 'Soup';
break;
case 'Main':
return 'Curry';
break;
case 'Desert':
return 'Ice Cream';
break;
default:
break;
}
}
}
$server = new soap_server();
$server->configureWSDL("foodservice", "urn:foodservice");
$server->register("food.getFood",
array("type" => "xsd:string"),
array("return" => "xsd:string"),
"urn:foodservice",
"urn:foodservice#getFood",
"rpc",
"encoded",
"Get food by type");
@$server->service($HTTP_RAW_POST_DATA);
?>
Run Code Online (Sandbox Code Playgroud)
客户:
<?php
require_once "nusoaplib/nusoap.php";
$client = new nusoap_client("http://localhost/SOAPServer.php?wsdl", true);
$error = $client->getError();
if ($error) {
echo "<h2>Constructor error</h2><pre>" . $error . "</pre>"; …Run Code Online (Sandbox Code Playgroud) 至于我鞭打网络,我可以看到大量关于如何设置NuSOAP并使用它在PHP中设置SOAP服务器和客户端的文章.
但是,它们似乎都没有指出使用它的任何优点,而不是PHP自己的本机SOAP库.有什么优点/缺点:
我想通过使用NuSOAP生成WSDL来通过SOAP查询一些内容.
我知道有很多与该主题有关的问题,但我没有成功地使代码适应我的特定问题.
我成功地生成了WSDL代码,它只返回一个结构数组(关联数组),但我宁愿返回一个包含整数变量,字符串变量和结构数组的对象(struct).
所以,这是用于返回结构数组的代码:
<?php
function getStuffs( $user='', $pass='' ) {
// here we can check user and pass and do whatever (if it isn't alright, we can throw exception or return NULL or sg. similar)
// .......
$stuff_array = array();
$stuff_array[] = array( 'id'=>122, 'name'=>'One stuff');
$stuff_array[] = array( 'id'=>213, 'name'=>'Another stuff');
$stuff_array[] = array( 'id'=>435, 'name'=>'Whatever stuff');
$stuff_array[] = array( 'id'=>65, 'name'=>'Cool Stuff');
$stuff_array[] = array( 'id'=>92, 'name'=>'Wow, what a stuff');
return …Run Code Online (Sandbox Code Playgroud) 我想连接到仅支持TLS 1.2的服务器.我可以指定哪些可能的密码来在PHP NUSOAP SoapClient创建中传输上下文?
<?php
$objSoapClient = new SoapClient(
"https://example.com/?wsdl",
array(
"encoding"=>"ISO-8859-1",
"stream_context"=>stream_context_create(
array(
"ssl"=>array("ciphers"=>"<????>")
)
)
)
);
?>
Run Code Online (Sandbox Code Playgroud)