Using Soap PHP

I am trying to insert data to a remote server through SOAP. But got the error below:

object (stdClass) # 3 (1) {["DataInsertResult"] => string (51) "Hata: DI - The value cannot be null. Parameter name: s"}

Here you can find the following code:

<?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" => " gerorge@emailprovider.com ", "InvitedBy" => "Mary J", "Job" => "Architect", "City" => "Newyork", ) ) ) )); var_dump($send); echo $client->DataInsertResponse; ?> 

How can I 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> gerorge@emailprovider.com </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, a few days later I got some interesting news ... php_soap cannot connect to 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> gerorge@emailprovider.com </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:

 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 
+4
source share
2 answers

This seems like a .NET error, you cannot solve it on the php side. but possibly a missing parameter.

For example: if my function

public void DataInsert (line test1, line s)

if s is passed as null.net, an error is thrown because "The value cannot be null. Parameter name: s"} "

http://www.posta-tr.com/MassDataAccepter/MassDataAccepter.asmx?op=DataInsert

  <DataInsert xmlns="http://tempuri.org/"> <Token>string</Token> <Data>string</Data> </DataInsert> 

I think that Data or Token is null, you passed only one parameter, and now Data is null, try sending parameter 2, first a token, and the second - data.

 <?php $client = new SoapClient("http://www.posta-tr.com/MassDataAccepter/MassDataAccepter.asmx?wsdl"); $connect = $client->Authenticate("accountname", "password"); $data = "<idRoot> <DataToDb> <Drow> <FName>George</FName> <LName>Houston</LName> <Email> gerorge@emailprovider.com </Email> <InvitedBy>Mary J</InvitedBy> <Job>Architect</Job> <City>Newyork</City> </Drow> </DataToDb> </idRoot>"; $send = $client->DataInsert($connect->AuthenticateResult,$data); var_dump($send); ?> 

Selamlar (:

+1
source

I think the parameters passed to the DataInsert are incorrect, it should be something like this:

 /* Get token key here */ $token = $tokenKey; $data = array( "idRoot" => array ( "DataToDb" => array( "Drow" => array ( "FName" => "George", "LName" => "Houston", "Email" => " gerorge@emailprovider.com ", "InvitedBy" => "Mary J", "Job" => "Architect", "City" => "Newyork", ) ) ) ); $params = array( 'Data' => $data, 'Token' => $token ); $client = new SoapClient( /* wsdl */ ); $response = $client->DataInsert($params); 
0
source

Source: https://habr.com/ru/post/1344784/


All Articles