Monday, December 21, 2009

Nusoap PHP Request (USING WSDL Document/literal)

// example 2
// include soap file
require_once('nusoap.php');
// set name space
$ns="urn:service";
// set end point
$endpoint = "https://localhost/MethodName";
// create client
$client = new soapclientw($endpoint);

if ( $client->getError() ) {
print "Soap Constructor Error:".
$client->getError()."";
}

$request = 'Yorr XML DATA';
$action = "MethodName";
$msg = $client->serializeEnvelope($request, '', array(), 'document', 'literal');
$result = $client->send($msg, $action, 60, 60);

if ($client->fault) { //soap_fault
print "Soap Fault: (". $client->fault->faultcode .") ".
$client->fault->faultstring. "";
}
elseif ( $client->getError() ) {
print "Soap Error: ". $client->getError() ."";
}
else {
print "Result: ";
print_r($result);
print "";
}

print 'Details:'.
'Request' .
htmlspecialchars( $client->request, ENT_QUOTES) .''.
'Response' .
htmlspecialchars( $client->response, ENT_QUOTES) .''.
'Debug' .
htmlspecialchars( $client->debug_str, ENT_QUOTES) .'';

Nusoap PHP Request (USING WSDL URL)

// example one using WSDL URL
// include nusoap file
require_once('nusoap.php');
// set the wsdl path
$wsdl="http://localhost/server.php?wsdl";
// crate client
$client=new soapclientw($wsdl, 'wsdl');
// set the parameter
$param=array('amount'=>'15.00');
// cal method and echo the resutl
echo $client->call('CalculateOntarioTax', $param);
// echo request and response
echo 'Request ' . htmlspecialchars($client->requestHeaders, ENT_QUOTES) . '';
echo 'Response ' . htmlspecialchars($client->responseHeaders, ENT_QUOTES) . ' ';

Tuesday, December 1, 2009

URL Rewriting Using .htacess file

URL Rewriting Using .htacess file

Our Aim is to

http://www.example.com/test/blog/var1/testFile.html

into dynamic URL

http://www.example.com/test/testFile.php?var1=var1&var2=testFile

using .htacess file

Create .htacess file in test directory

Now you directory structure is

www.example.com/test/

.htacess

testFile.php

In .htacess file write the code

Options +FollowSymlinks

RewriteEngine On

RewriteRule ^blog/([^/]+)/([^/]+)\.html$ /test/testFile.php?var1=$1&var1=$2 [QSA]

Now in testFile.php your code will be there

If you type URL in Browser

http://www.example.com/test/blog /var1/testFile.html

it will execute on server as

http://www.example.com/test/testFile.php?var1=var1&var2=testFile

if you want todo external redirecting the just change the .htacess code

Options +FollowSymlinks

RewriteEngine On

RewriteRule ^blog/([^/]+)/([^/]+)\.html$ /test/testFile.php?var1=$1&var1=$2 [R=301,L]