PHP Soap 的用法
我正在尝试通过 SOAP 将数据插入远程服务器。但出现以下错误:
object(stdClass)#3 (1) { ["DataInsertResult"]==> string(51) "Hata : DI - 值不能为空。参数名称: s" }
在这里您可以找到我的代码如下:
<?php
$client = new SoapClient("http://www.posta-tr.com/MassDataAccepter/MassDataAccepter.asmx?wsdl");
$connect = $client->Authenticate("accountname", "password");
$send = $client->DataInsert(array(
"idRoot" => array (
"DataToDb" => array(
"Drow" => array (
"FName" => "George",
"LName" => "Houston",
"Email" => "[email protected]",
"InvitedBy" => "Mary J",
"Job" => "Architect",
"City" => "Newyork",
)
)
)
));
var_dump($send);
echo $client->DataInsertResponse;
?>
我如何解决这个问题?
您好,在这里您可以看到我的网络服务提供商的 .net (?) 代码。我如何使用它作为 php 代码?
Webservice Url: http://www.posta-tr.com/MassDataAccepter/MassDataAccepter.asmx?wsdl
protected void btn_Save_Click(object sender, EventArgs e)
{
PwebS.MassDataAccepter mda = new PwebS.MassDataAccepter();
string Result = "Error!";
string Token = mda.Authenticate("user", "pass");
string data = @"<idRoot>
<DataToDb>
<Drow>
<FName>George</FName>
<LName>Houston</LName>
<Email>[email protected]</Email>
<InvitedBy>Mary J</InvitedBy>
<Job>Architect</Job>
<City>Newyork</City>
</Drow>
</DataToDb>
</idRoot>";
if (Token.Length > 30)
{
Result = mda.DataInsert(Token, data);
}
if (Result.Contains("Inserted : 1"))
lbl_Info.Text = "Data Inserted!";
else if (Result.Contains("Updated : 1"))
lbl_Info.Text = "There is same data in db! Duplicate Data!";
else
lbl_Info.Text = "Error!";
}
你好,几天后我得到了一个有趣的消息... php_soap 无法连接网络服务,但 nusoap 工作正常!下面您可以看到我的代码,但我收到了一个新错误,您可以在代码后面看到错误:)
<?PHP
require_once('includes/nusoap/nusoap.php');
$client = new nusoap_client("http://www.posta-tr.com/MassDataAccepter/MassDataAccepter.asmx?wsdl", "wsdl","", "", "", "");
$err = $client->getError();
if ($err) {
echo "<h2>Constructor error</h2><pre>" . $err . "</pre>";
}
$params = array(
'Username'=>'my_username',
'Password'=>'my_password'
);
$result = $client->call("Authenticate", $params, "", "", false, true);
if ($client->fault) {
echo "<h2>Fault</h2><pre>";
print_r($result);
echo "</pre>";
} else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error
echo "<h2>Error</h2><pre>" . $err . "</pre>";
} else {
// Display the result
echo "<h2>Result</h2><pre>";
print_r($result);
$tokenkey = $result['AuthenticateResult'];
echo $tokenkey;
echo "</pre>";
}
}
$veri = "<idRoot>
<DataToDb>
<Drow>
<FName>George</FName>
<LName>Houston</LName>
<Email>[email protected]</Email>
<InvitedBy>Mary J</InvitedBy>
<Job>Architect</Job>
<City>Newyork</City>
</Drow>
</DataToDb>
</idRoot>";
echo "<hr />";
$send = $client->call("DataInsert",$tokenkey,$veri);
var_dump($send);
?>
结果:
Result
Array
(
[AuthenticateResult] => 92528146-183B-4651-B852-6A1C97F1E908
)
92528146-183B-4651-B852-6A1C97F1E908 //This means we connect the webservice and we got "token"
bool(false) //This means there is an error in data
I'm triying to insert data a remote server via SOAP. But got the error below:
object(stdClass)#3 (1) { ["DataInsertResult"]=> string(51) "Hata : DI - Value cannot be null. Parameter name: s" }
Here you can find tehe my code below:
<?php
$client = new SoapClient("http://www.posta-tr.com/MassDataAccepter/MassDataAccepter.asmx?wsdl");
$connect = $client->Authenticate("accountname", "password");
$send = $client->DataInsert(array(
"idRoot" => array (
"DataToDb" => array(
"Drow" => array (
"FName" => "George",
"LName" => "Houston",
"Email" => "[email protected]",
"InvitedBy" => "Mary J",
"Job" => "Architect",
"City" => "Newyork",
)
)
)
));
var_dump($send);
echo $client->DataInsertResponse;
?>
How I can solve this problem?
Hi,Here you can see the .net (?) code of my webservice provider. How can i use this as php code?
Webservice Url: http://www.posta-tr.com/MassDataAccepter/MassDataAccepter.asmx?wsdl
protected void btn_Save_Click(object sender, EventArgs e)
{
PwebS.MassDataAccepter mda = new PwebS.MassDataAccepter();
string Result = "Error!";
string Token = mda.Authenticate("user", "pass");
string data = @"<idRoot>
<DataToDb>
<Drow>
<FName>George</FName>
<LName>Houston</LName>
<Email>[email protected]</Email>
<InvitedBy>Mary J</InvitedBy>
<Job>Architect</Job>
<City>Newyork</City>
</Drow>
</DataToDb>
</idRoot>";
if (Token.Length > 30)
{
Result = mda.DataInsert(Token, data);
}
if (Result.Contains("Inserted : 1"))
lbl_Info.Text = "Data Inserted!";
else if (Result.Contains("Updated : 1"))
lbl_Info.Text = "There is same data in db! Duplicate Data!";
else
lbl_Info.Text = "Error!";
}
Hi, after a few days i got an interesting news... php_soap can not connect the webservice but nusoap works fine! Below you can see my code but i got a new error you can see the error after the code :)
<?PHP
require_once('includes/nusoap/nusoap.php');
$client = new nusoap_client("http://www.posta-tr.com/MassDataAccepter/MassDataAccepter.asmx?wsdl", "wsdl","", "", "", "");
$err = $client->getError();
if ($err) {
echo "<h2>Constructor error</h2><pre>" . $err . "</pre>";
}
$params = array(
'Username'=>'my_username',
'Password'=>'my_password'
);
$result = $client->call("Authenticate", $params, "", "", false, true);
if ($client->fault) {
echo "<h2>Fault</h2><pre>";
print_r($result);
echo "</pre>";
} else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error
echo "<h2>Error</h2><pre>" . $err . "</pre>";
} else {
// Display the result
echo "<h2>Result</h2><pre>";
print_r($result);
$tokenkey = $result['AuthenticateResult'];
echo $tokenkey;
echo "</pre>";
}
}
$veri = "<idRoot>
<DataToDb>
<Drow>
<FName>George</FName>
<LName>Houston</LName>
<Email>[email protected]</Email>
<InvitedBy>Mary J</InvitedBy>
<Job>Architect</Job>
<City>Newyork</City>
</Drow>
</DataToDb>
</idRoot>";
echo "<hr />";
$send = $client->call("DataInsert",$tokenkey,$veri);
var_dump($send);
?>
The result:
Result
Array
(
[AuthenticateResult] => 92528146-183B-4651-B852-6A1C97F1E908
)
92528146-183B-4651-B852-6A1C97F1E908 //This means we connect the webservice and we got "token"
bool(false) //This means there is an error in data
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为传递给 DataInsert 的参数不正确,应该是这样的:
I think the params passed to DataInsert is incorrect, it should be like this:
这看起来像一个 .NET 错误,您无法在 php 端解决它。但可能缺少参数。
例如 :
如果我的函数为
public void DataInsert(string test1,string s)
如果 s 作为 null 传递,.net 将抛出错误,因为“值不能为 null。参数名称:s” }"
http://www.posta-tr.com/MassDataAccepter/MassDataAccepter.asmx?op=DataInsert
我认为数据或者 Token 为 null,您只传递了 1 个参数,现在 Data 为 null,
尝试发送 2 个参数,第一个是 Token,第二个是 Data。
塞拉姆拉尔(:
This looks like a .NET error, you cannot solve it on php side. but maybe a missing parameter.
For example :
if my function as
public void DataInsert(string test1,string s)
if s passed as null .net will throw an error as "Value cannot be null. Parameter name: s" }"
http://www.posta-tr.com/MassDataAccepter/MassDataAccepter.asmx?op=DataInsert
i think Data or Token is null, you passed only 1 parameter, and now Data is null,
try send 2 parameter, first is Token and Second is Data.
Selamlar (: