Call asp.net web service from PHP with multiple parameters
Try like this:
$client = new SoapClient("http://testurl/Test.asmx?WSDL");
$params->Param1 = 'Hello';
$params->Param2 = 'World!';
$result = $client->TestMethod($params)->TestMethodResult;
Call asp.net web service from PHP
Since HelloWorld is the method you are trying to call, try:
$result = $client->__soapCall('HelloWord', $params);
or
$result = $client->HelloWorld($params);
Where $params
are any parameters you need to send for the method.
Call A C# Web Service From PHP Client
This is the right Answer I found it by myself and I like to share it for other developers
<?php
//Use C# Web Service:
$client2 = new SoapClient("http://www.emadbook.com/TestWebService/Convert.asmx?WSDL");
$params = new ArrayObject();
$params->Celsius = 37;
$result = $client2->CelsiusToFahrenheit($params)->CelsiusToFahrenheitResult;
echo $result;
?>
how to call my asp.net web service from php?
This code is working fine for me...
<?php
require 'nusoap/lib/nusoap.php';
$client = new nusoap_client('http://localhost/prs_point/prs_point.asmx?WSDL', 'WSDL');
$error = $client->getError();
if ($error) {
die("client construction error: {$error}\n");
}
$param = array('inputData' => 'sample data');
$answer = $client->call('testAssignment', array('parameters' => $param), '', '', false, true);
$error = $client->getError();
if ($error) {
print_r($client->response);
print_r($client->getDebug());
die();
}
print_r($answer);
?>
web service call with more than one parameter
I think you can use like this
var firstName = document.getElementById("txtFirstName").value;
var lastName = document.getElementById("txtLastName").value;
data : "{'firstName':firstName,'lastName':lastName}"
Passing C# Web service Parameters to PHP Application
You could send the data as following. Convert it to a byte array and write it to the request stream:
[WebMethod]
public string POSTXml(string username, string password)
{
WebRequest req = null;
WebResponse rsp = null;
try
{
string data = "user=" + username + "&password=" + password;
string url = "http://xyz.in/getuser.php/";
byte[] buffer = Encoding.ASCII.GetBytes(data);
HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(url);
WebReq.Method = "POST";
WebReq.ContentType = "application/x-www-form-urlencoded";
WebReq.ContentLength = buffer.Length;
using (Stream PostData = WebReq.GetRequestStream())
{
PostData.Write(buffer, 0, buffer.Length);
HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
using (Stream stream = WebResp.GetResponseStream())
{
using (StreamReader strReader = new StreamReader(stream))
{
return strReader.ReadToEnd();
}
}
WebResp.Close();
}
}
catch (Exception e)
{
throw new Exception("There was a problem sending the message");
}
return String.Empty;
}
How to pass multiple parameters in a querystring
Query_string
(Following is the text of the linked section of the Wikipedia entry.)
Structure
A typical URL containing a query string is as follows:
http://server/path/program?query_string
When a server receives a request for such a page, it runs a program (if configured to do so), passing the query_string unchanged to the program. The question mark is used as a separator and is not part of the query string.
A link in a web page may have a URL that contains a query string, however, HTML defines three ways a web browser can generate the query string:
- a web form via the ... element
- a server-side image map via the ismap attribute on the element with a construction
- an indexed search via the now deprecated element
Web forms
The main use of query strings is to contain the content of an HTML form, also known as web form. In particular, when a form containing the fields field1, field2, field3 is submitted, the content of the fields is encoded as a query string as follows:
field1=value1&field2=value2&field3=value3...
- The query string is composed of a series of field-value pairs.
- Within each pair, the field name and value are separated by an equals sign. The equals sign may be omitted if the value is an empty string.
- The series of pairs is separated by the ampersand, '&' (or semicolon, ';' for URLs embedded in HTML and not generated by a ...; see below).
While there is no definitive standard, most web frameworks allow multiple values to be associated with a single field:
field1=value1&field1=value2&field1=value3...
For each field of the form, the query string contains a pair field=value. Web forms may include fields that are not visible to the user; these fields are included in the query string when the form is submitted
This convention is a W3C recommendation. W3C recommends that all web servers support semicolon separators in addition to ampersand separators[6] to allow application/x-www-form-urlencoded query strings in URLs within HTML documents without having to entity escape ampersands.
Technically, the form content is only encoded as a query string when the form submission method is GET. The same encoding is used by default when the submission method is POST, but the result is not sent as a query string, that is, is not added to the action URL of the form. Rather, the string is sent as the body of the HTTP request.
Can i send multiple values into this web service request
Try doing this:
array('symbol'=>'^NZ50, QQQ, SPY')
Based on the usage here if you enter ^NZ50, QQQ, SPY
(separated by commas with spaces - not ^NZ50,QQQ,SPY
) it returns an XML response with the <symbol>
data for the 3.
Related Topics
Setting Up a Ubuntu/Apache/PHP MAChine to Send Email
How to Post a Large Amount of Data Within PHP Curl Without Memory Overhead
What Is Difference Between PHP Cli and PHP Cgi
PHP File Uploads Doesnot Read $_Files['Image']
Extract Url's from a String Using PHP
Fully Understanding Pdo Attr_Persistent
Storage in Laravel Says Symlink - No Such File
How to Get List of Defined Namespaces
Any Aws Eb Laravel Route Getting 404 Not Found Nginx/1.16.1
Find Duplicate Value in Multi-Dimensional Array
Have Gd Get Image from Binary String
Php: Possible to Automatically Get All Posted Data and Multiple Checkbox Unchecked
How to Work with Many-To-Many Relations in Yii2
Add Allow_Url_Fopen to My PHP.Ini Using .Htaccess