Top Banner
SOAP and WSDL DIG 4104c Web Design Workshop Michael Moshell Spring 2013 annalaurabrown. com cubaninsider.blogsp ot.com
22

SOAP and WSDL DIG 4104c Web Design Workshop Michael Moshell Spring 2013 annalaurabrown.com cubaninsider.blogspot.com.

Jan 02, 2016

Download

Documents

Norman Chandler
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: SOAP and WSDL DIG 4104c Web Design Workshop Michael Moshell Spring 2013 annalaurabrown.com cubaninsider.blogspot.com.

SOAP and WSDL

DIG 4104c Web Design WorkshopMichael Moshell

Spring 2013

annalaurabrown.com cubaninsider.blogspot.com

Page 2: SOAP and WSDL DIG 4104c Web Design Workshop Michael Moshell Spring 2013 annalaurabrown.com cubaninsider.blogspot.com.

cubaninsider.blogspot.com

We're not really washing weasels ...We're CONNECTING programs on

different COMPUTERS.

galloinspires.com

Page 3: SOAP and WSDL DIG 4104c Web Design Workshop Michael Moshell Spring 2013 annalaurabrown.com cubaninsider.blogspot.com.

cubaninsider.blogspot.com

We're not really washing weasels ...We're CONNECTING programs on

different COMPUTERS.

The Lead Retrieval Story

At a conference, Exhibitorswant Leads – names and

contact information for follow-up marketing.

galloinspires.com

Page 4: SOAP and WSDL DIG 4104c Web Design Workshop Michael Moshell Spring 2013 annalaurabrown.com cubaninsider.blogspot.com.

Attendees have badges (with barcodes)or cards (with chips or mag stripes)

Which are scannedat the booths ...

Data from the scannersgoes onto RAM sticks (or through the Internet)to sales people who follow up, next dayor next week,

to close the sale, build a relationship

bartizan.com

bartizan.com

expectnation.com

Page 5: SOAP and WSDL DIG 4104c Web Design Workshop Michael Moshell Spring 2013 annalaurabrown.com cubaninsider.blogspot.com.

Our problem: Making the cards

Clientregisters

viabrowser

Clientregisters

viabrowser

Onlinesystem

capturesdata

Sendsdata to

mag cardcomputer

Onlinesystem

capturesdata

Sendsdata to

mag cardcomputer

mag cardcomputer

sendsdata to

mag cardprinter

mag cardcomputer

sendsdata to

mag cardprinter

zebra.com

Page 6: SOAP and WSDL DIG 4104c Web Design Workshop Michael Moshell Spring 2013 annalaurabrown.com cubaninsider.blogspot.com.

Our solution (pre-SOAP):Polling a PHP "server"

Clientregisters

viabrowser

Clientregisters

viabrowser

regmasterwrites

text files

regmasterwrites

text files

mag cardcomputer

polls (repeatedly asks)"do you have

$asknumber yet?

mag cardcomputer

polls (repeatedly asks)"do you have

$asknumber yet?

nextnumber.txttrans21044.txttrans21045.txttrans21046.txt...

PHP server:$asknumber ==

nextnumber.txt?

if so,send

trans($asknumber)

if not,send "NO"

PHP server:$asknumber ==

nextnumber.txt?

if so,send

trans($asknumber)

if not,send "NO"

nextnumber.txttrans21044.txttrans21045.txttrans21046.txt...

$asknumber?

NOortext file

Page 7: SOAP and WSDL DIG 4104c Web Design Workshop Michael Moshell Spring 2013 annalaurabrown.com cubaninsider.blogspot.com.

Our solution (pre-SOAP):Polling a PHP "server"

Clientregisters

viabrowser

Clientregisters

viabrowser

regmasterwrites

text files

regmasterwrites

text files

runget.phploops and

asks, every 2 seconds"Do you have 21047?

runget.phploops and

asks, every 2 seconds"Do you have 21047?

nextnumber.txttrans21044.txttrans21045.txttrans21046.txt...

runsend.phprunsend.php

nextnumber.txttrans21044.txttrans21045.txttrans21046.txt...

21047?

NOortext file

Page 8: SOAP and WSDL DIG 4104c Web Design Workshop Michael Moshell Spring 2013 annalaurabrown.com cubaninsider.blogspot.com.

Our solution (pre-SOAP):Polling a PHP "server"

Review the code: runsend, runget.

One fixup: The transfer dataShould be urlencoded!

This is regular text, with punctuation, said O'Reilly

URLencoded:This+is+regular+text%2C+with+punctuation%2C+said+O%27Reilly

Page 9: SOAP and WSDL DIG 4104c Web Design Workshop Michael Moshell Spring 2013 annalaurabrown.com cubaninsider.blogspot.com.

Our solution (pre-SOAP):Polling a PHP "server"

Clientregisters

viabrowser

Clientregisters

viabrowser

regmasterwrites

text files

regmasterwrites

text files

runget.phploops and

asks, every 2 seconds"Do you have 21047?

runget.phploops and

asks, every 2 seconds"Do you have 21047?

nextnumber.txttrans21044.txttrans21045.txttrans21046.txt...

runsend.phprunsend.php

nextnumber.txttrans21044.txttrans21045.txttrans21046.txt...

21047?

NOortext fileAdvantages:

HTTPS all the way; firewall OK

Page 10: SOAP and WSDL DIG 4104c Web Design Workshop Michael Moshell Spring 2013 annalaurabrown.com cubaninsider.blogspot.com.

Our solution (pre-SOAP):Polling a PHP "server"

Clientregisters

viabrowser

Clientregisters

viabrowser

regmasterwrites

text files

regmasterwrites

text files

runget.phploops and

asks, every 2 seconds"Do you have 21047?

runget.phploops and

asks, every 2 seconds"Do you have 21047?

nextnumber.txttrans21044.txttrans21045.txttrans21046.txt...

runsend.phprunsend.php

nextnumber.txttrans21044.txttrans21045.txttrans21046.txt...

21047?

NOortext fileDisadvantages:

Polling uses CPU and Internetresources; fragile synchronization

Page 11: SOAP and WSDL DIG 4104c Web Design Workshop Michael Moshell Spring 2013 annalaurabrown.com cubaninsider.blogspot.com.

21047?

NOortext file

Fragile synchronization?

Runget must know which number to ask for.If runsend somehow misses a number, system hangs.

Better way: Instead of asking for 21047, ask"what do you have that's new?

SO let's design a solution using SOAP.

Page 12: SOAP and WSDL DIG 4104c Web Design Workshop Michael Moshell Spring 2013 annalaurabrown.com cubaninsider.blogspot.com.

SOAP comes in two flavors(scented and unscented? Nope ...)

WITH and WITHOUT weasels!

(Well, really ... w and w/o WSDL.)

-- Web Service Description Language

Page 13: SOAP and WSDL DIG 4104c Web Design Workshop Michael Moshell Spring 2013 annalaurabrown.com cubaninsider.blogspot.com.

SOAP comes in two flavors(scented and unscented? Nope ...)

WITH and WITHOUT weasels!

(Well, really ... w and w/o WSDL.)

So let's look at without, first.

Page 14: SOAP and WSDL DIG 4104c Web Design Workshop Michael Moshell Spring 2013 annalaurabrown.com cubaninsider.blogspot.com.

The Soap "Hello World" example(thanks to://php.net/manual/de/soapserver.construct.php

<?php // Client example

$client = new SoapClient(null, array( 'location' => "http://regmaster3.com/sandbox/soapserver.php",

'uri' => "http://regmaster3.com/sandbox/soapserver.php", 'trace' => 1 ));

echo $return = $client->__soapCall("helloWorld",array("Delighted to be here!"));

?>

Two underscores: a built-in method soapCallThe function of the service to be called

the data to be passed to that service

Page 15: SOAP and WSDL DIG 4104c Web Design Workshop Michael Moshell Spring 2013 annalaurabrown.com cubaninsider.blogspot.com.

The Soap "Hello World" example(thanks to://php.net/manual/de/soapserver.construct.php

<?php // Client example

$client = new SoapClient(null, array( 'location' => "http://regmaster3.com/sandbox/soaptut4s.php",

'uri' => "http://regmaster3.com/sandbox/soaptut4s.php", 'trace' => 1 ));

echo $return = $client->__soapCall("helloWorld",array("Delighted to be here!"));

?>

Two underscores: a built-in method soapCallThe function of the service to be called

the data to be passed to that service

Page 16: SOAP and WSDL DIG 4104c Web Design Workshop Michael Moshell Spring 2013 annalaurabrown.com cubaninsider.blogspot.com.

The Soap "Hello World" example(thanks to://php.net/manual/de/soapserver.construct.php

<?php // Client example

$client = new SoapClient(null, array( 'location' => "http://regmaster3.com/sandbox/soaptut4s.php",

'uri' => "http://regmaster3.com/sandbox/soaptut4s.php", 'trace' => 1 ));

echo $return = $client->__soapCall("helloWorld",array("Delighted to be here!"));

?>

Two underscores: a built-in method soapCallThe function of the service to be called

the data to be passed to that service

Page 17: SOAP and WSDL DIG 4104c Web Design Workshop Michael Moshell Spring 2013 annalaurabrown.com cubaninsider.blogspot.com.

The Soap "Hello World" example(thanks to://php.net/manual/de/soapserver.construct.php

<?php // Server example 'soapserver.php'prototypeclass MyClass { public function helloWorld() {

return 'Hallo Welt you made it! '. print_r(func_get_args(), true); }

} try {

$server = new SOAPServer( NULL, array('uri' => 'http://regmaster3.com/sandbox/soapserver.php' )

); $server->setClass('MyClass');

$server->handle(); // This must be the last action. It "sets the mouse-trap"}

catch (SOAPFault $f) { print $f->faultstring;}

?>

Page 18: SOAP and WSDL DIG 4104c Web Design Workshop Michael Moshell Spring 2013 annalaurabrown.com cubaninsider.blogspot.com.

The Soap "Hello World" example(thanks to://php.net/manual/de/soapserver.construct.php

<?php // Server example 'soapserver.php'prototypeclass MyClass { public function helloWorld() {

return 'Hallo Welt you made it! '. print_r(func_get_args(), true); }

} try {

$server = new SOAPServer( NULL, array('uri' => 'http://regmaster3.com/sandbox/soapserver.php' )

); $server->setClass('MyClass');

$server->handle(); // This must be the last action. It "sets the mouse-trap"}

catch (SOAPFault $f) { print $f->faultstring;}

?>

Page 19: SOAP and WSDL DIG 4104c Web Design Workshop Michael Moshell Spring 2013 annalaurabrown.com cubaninsider.blogspot.com.

The Soap "Hello World" example(thanks to://php.net/manual/de/soapserver.construct.php

<?php // Server example 'soapserver.php'prototypeclass MyClass { public function helloWorld() {

return 'Hallo Welt you made it! '. print_r(func_get_args(), true); }

} try {

$server = new SOAPServer( NULL, // We discuss when WSDL comes uparray('uri' => 'http://regmaster3.com/sandbox/soapserver.php' )

); $server->setClass('MyClass');

$server->handle(); // This must be the last action. It "sets the mouse-trap"}

catch (SOAPFault $f) { print $f->faultstring;}

?>

Page 20: SOAP and WSDL DIG 4104c Web Design Workshop Michael Moshell Spring 2013 annalaurabrown.com cubaninsider.blogspot.com.

Advantages over cURL

1)SOAP does the work of establishing the connection between client & server

2) SOAP communicates via objects, not text files (urlencoding, etc.)

Design Process:

1) Build a synchronous polling version, to reuse my existing code (dumb though it is.)

2) Build an asynchronous polling version – "have you got anything new".

3) Build a PUSH version instead of a Pull-Pull-Pull version

Huh? That is, make the registration system tell the mag printer when to print.Instead of having the mag print ask-ask-ask

Disadvantage of this approach: The mag printer must now offer a public websitewhich can be accessed by the reg system to initiate the transaction.

Page 21: SOAP and WSDL DIG 4104c Web Design Workshop Michael Moshell Spring 2013 annalaurabrown.com cubaninsider.blogspot.com.

Moving on to WSDL

Using someone else's service is challenging.

Our 'Hallo Welt' example required that we know exactly what functionsthe service offered. If we got it wrong, the only error message would bea complex stack trace (or nothing, if the server was "buttoned up" for production.

It would be desirable if Web Services were 'self-describing'.

To describe something you need a language. Hence, WSDL

http://devzone.zend.com/2202/php-and-soap-first-steps/

A very nice tutorial

Go through the 'boxing' example using soapUI

berm.co.nz

Page 22: SOAP and WSDL DIG 4104c Web Design Workshop Michael Moshell Spring 2013 annalaurabrown.com cubaninsider.blogspot.com.

Moving on to WSDL

Using someone else's service is challenging.

Our 'Hallo Welt' example required that we know exactly what functionsthe service offered. If we got it wrong, the only error message would bea complex stack trace (or nothing, if the server was "buttoned up" for production.

It would be desirable if Web Services were 'self-describing'.

To describe something you need a language. Hence, WSDL

<< Out of time for lesson planning. We peek briefly at WSDL, then adjourn.>>

ASSIGNMENT: Work through the tutorial listed on the previous page.

Be able to explain in your own words, what each element in a WSDL document does.