Solved

Using NuSoap

Posted on 2010-08-29
2
476 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 110

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

623 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