Thursday, March 1, 2007

Assignment #7

1. The line is telling us that it is using Cocoon, while using a component called XmlHttpTransformer.
The next lines are defining the action that is requested which are a stock quotes.
The following lines are the body of the code which is a soap request. It is calling the methods-delayed-quotes SOAP method to get the quote for IBM. This will be in string format.
The next lines are defining yet another method which will be currency exchange.
The exchange rates for the United States and Japan are required for this, which are also strings.
All of this code is the request of the information.

2. Once again it is telling us that we are using Cocoon while using a component called XmlHttpTransformer.
This time though, we are calling for the information that number 1 requested.
The result, which is now calling for a float command, is 82.92 in US currency.
After using the Japan exchange rate, we see that the stock is worth 122.52

3.1 WSDL uses the following elements:
Types – a container for data type definitions using some type system (such as XSD).
Message – an abstract, typed definition of the data being communicated.
Operation – an abstract description of an action supported by the service.
Port Type – an abstract set of operations supported by one or more endpoints.
Binding – a concrete protocol and data format specification for a particular port type.
Port – a single endpoint defined as a combination of a binding and a network address.
Service – a collection of related endpoints.

3.2 The code for a soap request and response is almost identical according to this article. The only difference is the middle lines. In the request, we see that it is requesting the lasttradeprice for the stock matching DIS. In the response, we are asking for the result which was 34.5.

3.3 A port type is a named set of abstract operations and the abstract messages involved. It is also one of the elements that WSDL uses.

3.4 An error message or status information for SOAP message is contained within a fault element.

3.5 MIME Binding is used to bind different types of data together. The following are defined:
multipart/related
text/xml
application/x-www-form-urlencoded (the format used to submit a form in HTML)
Others (by specifying the MIME type string)

4. #!perl -w
use SOAP::Transport::HTTP;
SOAP::Transport::HTTP::CGI

-> dispatch_to('Calculator')

-> handle;


package Calculator;


sub add {

my ($class, $a, $b) = @_;

return $a+$b;

}


sub subtract {

my ($class, $a, $b) = @_;

return $a-$b;

}


sub multiply {

my ($class, $a, $b) = @_;

return $a*$b;

}


sub divide {

my ($class, $a, $b) = @_;

return $a/$b;

}

No comments: