php web service authentication php web service file transfer
What is web service ?
For web service you need to know what is xml ? because all communication is go through the xml.
What is XML ?
Xml is a subset of Standard Generalized markup Language (SGML) Its design goal is to be as powerful and flexible as SGML with less complexity.
Web Service:
According to the W3c, Web services "provide a standard means of inter-operating between different software applications,running on variety of platforms and frameworks".
SOAP :
SOAP acronym that stood for Simple Object Access Protocol .SOAP is powerful tool for comminication between different different operating system and frameworks.SOAP is tied to xml b'cause all messages sent to and from a soap server are sent in soap envelope that is xml.
Here we are calling dot net web service in php.For that you must know how to create a web service in dot net.I am not big fan of not net but I manage to create a simple dot net web service that is called in php.This web service simple return factorial of given number.
VB Dot Net Code for Web Service Factorial Method :
What is web service ?
For web service you need to know what is xml ? because all communication is go through the xml.
What is XML ?
Xml is a subset of Standard Generalized markup Language (SGML) Its design goal is to be as powerful and flexible as SGML with less complexity.
Web Service:
According to the W3c, Web services "provide a standard means of inter-operating between different software applications,running on variety of platforms and frameworks".
SOAP :
SOAP acronym that stood for Simple Object Access Protocol .SOAP is powerful tool for comminication between different different operating system and frameworks.SOAP is tied to xml b'cause all messages sent to and from a soap server are sent in soap envelope that is xml.
Here we are calling dot net web service in php.For that you must know how to create a web service in dot net.I am not big fan of not net but I manage to create a simple dot net web service that is called in php.This web service simple return factorial of given number.
VB Dot Net Code for Web Service Factorial Method :
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class Service
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function factorial(ByVal number As Long) As String
Dim result As Long = 1
If number > 0 Then
Dim i As Integer
For i = 1 To number
result = result * i
Next i
End If
Return result
End Function
End Class
PHP Web Service client
Note:PHP Web services required NuSoap Library Download it from
Download Nusoap Lib
PHP Web service code:
<?php
// includes nusoap class
require_once('../lib/nusoap.php');
// Create object
$client = new nusoap_client('http://localhost:1587/sampledotnetWebService/Service.asmx?wsdl', true);//set your dot net web service url
$err = $client->getError();
if ($err) {
// error if any
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
}
// Call mathod
$result = $client->call('factorial', array('number' => '5'));
// fault if any
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>';
echo "factorial for 5 = ".$result['factorialResult'];
echo '</pre>';
}
}
//Display the request and response
?>