Solved

Using NuSoap

Posted on 2010-08-29
2
459 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

706 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

22 Experts available now in Live!

Get 1:1 Help Now