Solved

Using NuSoap

Posted on 2010-08-29
2
462 Views
Last Modified: 2013-12-13
Hi all ,
To develop SOAP web service , i use nusoap. i read the code and some example. It is clear for me.
But our partner request authentication by using header in SOAP message. I find the function in nusoap library for this but it doesn't have.Would anybody help me to find the solution for authencation by header ?
how to do it if we use nusoap library. Tks so much

0
Comment
Question by:dinhchung82
2 Comments
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 33557996
I am going to ask you to consider going in a different direction.  Do not use SOAP at all.  Instead choose a RESTful design pattern.

In REST, your authentication will be made with an API key that will be transmitted on every request.  If you put your REST service behind SSL, the API key is pretty safe and secure.

The reason for choosing REST over SOAP is very simple.  REST is easy to use.  SOAP introduces the idea of a "contract" between the services, where each side must do complex actions in certain orders.  This is a sure recipe for confusion as the HUGE number of questions about "Why can't I get SOAP to work?" clearly shows.  In contrast, I never see anyone posting a question at EE about how to get REST to work!

Some examples of successful REST interfaces include the Yahoo and Google Geocoders, and even the client-server nature of the WWW itself.
http://en.wikipedia.org/wiki/Representational_State_Transfer

Here is a little code snippet that will show you a simple REST application.  It takes a first name and returns the last name.  REST applications can return any data string - XML, JSON, and CSV strings are common.

Best of luck with it, ~Ray
<?php // RAY_REST_get_last_name.php
error_reporting(E_ALL);



// DEMONSTRATE HOW A RESTFUL WEB SERVICE WORKS
// CALLING EXAMPLE:
// file_get_contents('http://laprbass.com/RAY_REST_get_last_name.php?key=ABC&name=Ray');



// OUR DATA MODEL CONTAINS ALL THE ANSWERS - THIS COULD BE A DATA BASE QUERY - AS COMPLEX AS NEEDED
$dataModel
= array
( 'Brian'   => 'Portlock'
, 'Ray'     => 'Paseur'
, 'Richard' => 'Quadling'
)
;


// TEST THE API KEY - THE ASSUMPTION IS FAILURE
$key = FALSE;

// IF THE URL CONTAINS THE KEY
if (isset($_GET["key"])) $key = $_GET["key"];

// IF THE KEY FAILS TO MATCH OUR OUR REQUIRED 'ABC'
if ($key !== 'ABC') die('BOGUS API KEY');



// LOOK UP THE LAST NAME - THE ASSUMPTION IS FAILURE
$name="?";

// IF THE URL CONTAINS THE FIRST NAME
if (isset($_GET["name"])) $name = $_GET["name"];

// IF THE URL NAME IS FOUND IN THE DATA MODEL
if (array_key_exists($name, $dataModel))
{
    // RETURNS THE LAST NAME FROM THE DATA MODEL
    die("$dataModel[$name]");
}

// RETURNS THE UNKNOWN NAME INDICATOR
else die('UNKNOWN');

Open in new window

0
 
LVL 5

Author Closing Comment

by:dinhchung82
ID: 33578271
Thanks genius , i try to study about Rest ;)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now