Archive for December, 2007

CHAPTER 20 WEB SERVICES addFunction() void SoapServer->addFunction (Web site)

Friday, December 21st, 2007

CHAPTER 20 WEB SERVICES addFunction() void SoapServer->addFunction (mixed functions) You can make a function available to clients by exporting it using the addFunction() method. In the WSDL file, there is only one function to implement, getQuote(). It takes $boxer as a lone parameter, and returns a string. Let s create this function and expose it to connecting clients: addFunction(”getQuote”); ?> When two or more functions are defined in the WSDL file, you can choose which ones are to be exported by passing them in as an array, like so: $soapserver->addFunction(array(”getQuote”,”someOtherFunction”); Alternatively, if you would like to export all functions defined in the scope of the SOAP server, you can pass in the constant, SOAP_FUNCTIONS_ALL, like so: $soapserver->addFunction(array(SOAP_FUNCTIONS_ALL); It s important to understand that exporting the functions is not all that you need to do to produce a valid SOAP server. You also need to properly process incoming SOAP requests, a task handled for you via the method handle(). This method is introduced next. handle() void SoapServer->handle ([string soap_request]) Incoming SOAP requests are received by way of either the input parameter soap_request or the PHP global $HTTP_RAW_POST_DATA. Either way, the method handle() will automatically direct the request to the SOAP server for you. It s the last method executed in the server code. You call it like this:
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.

508 CHAPTER 20 WEB SERVICES soap.wsdl_cache_enabled Scope:

Thursday, December 20th, 2007

508 CHAPTER 20 WEB SERVICES soap.wsdl_cache_enabled Scope: PHP_INI_ALL; Default value: 1 This directive determines whether the WSDL caching feature is enabled. soap.wsdl_cache_dir Scope: PHP_INI_ALL; Default value: /tmp This directive determines the location where WSDL documents are cached. soap.wsdl_cache_ttl Scope: PHP_INI_ALL; Default value: 86400 This directive determines the time, in seconds, that a WSDL document is cached. SoapServer() object SoapServer->SoapServer (mixed wsdl [, array options]) The SoapServer() constructor instantiates a new instance of the SoapServer class in WSDL or non-WSDL mode. If you require WSDL mode, you need to assign the wsdlparameter the WSDL file s location, or else set it to NULL. The discretionary options parameter is an array used to set one or both of the following options: actor: Identifies the SOAP server as an actor, defining its URI. soap_version: Determines the supported SOAP version, and must be set with the syntax SOAP_x_y, where x is an integer specifying the major version number, and y is an integer specifying the corresponding minor version number. For example, SOAP version 1.2 would be assigned as SOAP_1_2. The following example creates a SoapServer object referencing the boxing.wsdl file: $soapserver = new SoapServer(”boxing.wsdl”); Of course, if the WSDL file resides on another server, you can reference it using a valid URI. For example: $soapserver = new SoapServer(”http://www.example.com/boxing.wsdl”); However, creating a SoapServerobject is only one task of several required to create a basic SOAP server. Next, you need to export at least one function, a task accomplished using the addFunction() method, introduced next. Note If you re interested in exposing all methods in a class through the SOAP server, use the method setClass(), introduced later in this section.
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.

CHAPTER 20 WEB SERVICES Returns quote from (Web hosting support)

Wednesday, December 19th, 2007

CHAPTER 20 WEB SERVICES


Returns quote from famous pugilists
Important Configuration Directives There are three important configuration directives that you need to keep in mind when building SOAP services using the native SOAP extension. These directives are introduced in this section.
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.

506 CHAPTER (Starting a web site) 20 WEB SERVICES 1)); $temperature

Tuesday, December 18th, 2007

506 CHAPTER 20 WEB SERVICES 1)); $temperature = $client->getTemp($zipcode); echo htmlspecialchars($client->__getLastResponse()); ?> This example returns (formatted for readability): 76.0 Creating a SOAP Server Creating a SOAP server with the new native SOAP extension is easier than you think. Although several server-specific methods are provided with the SOAP extension, only three methods are required to create a complete WSDL-enabled server. This section introduces these and other methods, guiding you through the process of creating a functional SOAP server as the section progresses. The next section, SOAP Client and Server Interaction, offers a complete working example of the interaction between a WSDL-enabled client and server created using this extension. To illustrate this, the examples in the upcoming section refer to Listing 20-12, which offers a sample WSDL file. Directly following the listing, a few important SOAP configuration directives are introduced that you need to keep in mind when building SOAP services using this extension. Listing 20-12. A Sample WSDL File (boxing.wsdl)
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

CHAPTER 20 WEB SERVICES This example returns: (Web host sites)

Monday, December 17th, 2007

CHAPTER 20 WEB SERVICES This example returns: It’s 74 degrees at zipcode 20171. __getLastRequest() string SoapClient->__getLastRequest() When you re debugging, it s useful to view the SOAP request in its entirety, headers and all. You can do so by turning on tracing when creating the SoapClient object, and invoking the __getLastRequest() method after a SOAP request has been executed. This is best explained with an example: 1)); $temperature = $client->getTemp($zipcode); echo htmlspecialchars($client->__getLastRequest()); ?> This example returns (formatted for readability): 20171 __getLastResponse() object SoapClient->__getLastResponse() The __getLastRequest() method is useful for reviewing the SOAP request in its entirety, envelope and all. When debugging, it s equally useful to review the response, accomplished using the __getLastResponse() method. As is the case with __getLastRequest(), tracing must be turned on. Consider an example:
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.

Fedora web server - 504 CHAPTER 20 WEB SERVICES soap_version:

Saturday, December 15th, 2007

504 CHAPTER 20 WEB SERVICES soap_version: This parameter specifies whether SOAP version 1.1 or 1.2 should be used. This defaults to version 1.1. trace: If you would like to examine SOAP request and response envelopes, you ll need to enable this by setting it to 1. Establishing a connection to a Web Service is trivial. The following example creates a SoapClient object that references the XMethods.net Weather Web Service, first introduced in the NuSOAP discussion earlier in this chapter: However, just referencing the Web Service really doesn t do you much good. You ll want to learn more about the methods exposed by this Web Service. Of course, you can open up the WSDL document in the browser or a WSDL viewer. However, you can also retrieve the methods programmatically using the __getFunctions()method, introduced next. __getFunctions() array SoapClient->__getFunctions() The __getFunctions() method returns an array consisting of all methods exposed by the service referenced by the SoapClient object. The following example establishes a connection to the XMethods.net Weather Web Service and retrieves a list of available methods: __getFunctions()); ?> This example returns: array(1) { [0]=> string(30) “float getTemp(string $zipcode)” }; A single exposed method has been returned, getTemp(), which accepts a ZIP code as its lone parameter. The following example uses this method: getTemp($zipcode).” degrees at zipcode $zipcode.”; ?>
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.

Web design portfolio - CHAPTER 20 WEB SERVICES Prerequisites PHP s SOAP

Friday, December 14th, 2007

CHAPTER 20 WEB SERVICES Prerequisites PHP s SOAP extension requires the GNOME XML library. You can download the latest stable libxml2 package from http://www.xmlsoft.org/. Binaries are also available for the Windows platform. Version 2.5.4 or greater is required. You ll also need to configure PHP with the –enable-soap extension. Creating a SOAP Client Creating a SOAP client with the new native SOAP extension is easier than you think. Although several client-specific methods are provided with the SOAP extension, only SoapClient() is required to create a complete WSDL-enabled client object. Once created, it s just a matter of calling the SOAP server s exposed functions. The SoapClient() method and several others are introduced next, guiding you through the process of creating a functional SOAP client as the section progresses. In the later section, SOAP Client and Server Interaction, you ll find a complete working example of interaction between a client and server created using this extension. SoapClient() object SoapClient->SoapClient (mixed wsdl [, array options]) The SoapClient() constructor instantiates a new instance of the SoapClient class. The wsdl parameter determines whether the class will be invoked in WSDL or non-WSDL mode. If the former, then the parameter will point to the WSDL file; otherwise, it will be set to null. The discretionary options parameter is an array that accepts the following parameters: actor: This parameter specifies the name, in URI format, of the role that a SOAP node must play in order to process the header. compression: This parameter specifies whether data compression is enabled. Presently, gzip and x-gzip are supported. According to the TODO document, support is planned for HTTP compression. exceptions: Enabling this parameter turns on the exception-handling mechanism. It is enabled by default. login: If HTTP authentication is used to access the SOAP server, this parameter specifies the username. password: If HTTP authentication is used to access the SOAP server, this parameter specifies the password. proxy_host: This parameter specifies the name of the proxy host when connecting through a proxy server. proxy_login: This parameter specifies the proxy server username if one is required. proxy_password: This parameter specifies the proxy server password if one is required. proxy_port: This parameter specifies the proxy server port when connecting through a proxy server.
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.

502 CHAPTER 20 WEB SERVICES When debugging

Thursday, December 13th, 2007

502 CHAPTER 20 WEB SERVICES When debugging via the client, you can begin accessing debugging information via the property debug_str, like so: echo $client->debug_str; Because the returned string is quite lengthy, it will be difficult to read if you output it to the browser. You can improve its readability by replacing all newline characters with the br tag via the nl2br() function: echo nl2br($soapclient->debug_str); When debugging via the server, the debugging information will automatically be appended to any response. Interestingly, you can also enable server debugging from the client side by appending ?debug=1 to the Web Service endpoint URL. This causes the server to automatically append the debugging information to the response, as if debugging were enabled on the server side. Two additional debugging attributes are available to the client: request: Retrieves the request header and accompanying SOAP message. It s called like so: echo $soapclient->request; response: Retrieves the request response header and its accompanying SOAP message. It s called like so: echo ‘

‘.$soapclient->response.’‘; Secure Connections Security should always be a subject of considerable concern when developing Internet-based applications. One of the de facto security safeguards in widespread use today is the Secure Sockets Layer (SSL) protocol, used to encrypt traffic sent over the Internet. NuSOAP supports SSL connections if the cURL extension is configured for PHP. Due to this extension s popularity, it s been bundled with PHP 5, and is enabled by configuring PHP with the –with-curl option. Secure connections are initiated as is done via the Web browser, by prefacing the domain address with https rather than http. PHP 5 s SOAP Extension In response to the community clamor for Web Services enabled applications, and the popularity of third-party SOAP extensions, a native SOAP extension was incorporated into PHP 5. This section introduces this new object-oriented extension, offering several examples demonstrating how easy it is to create SOAP clients and servers. Along the way, you ll learn more about many of the functions and methods available through this extension. Before you can follow along with the accompanying examples, you need to take care of a few prerequisites, which are discussed next.
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.

Cedant web hosting - CHAPTER 20 WEB SERVICES 501 The soap_fault

Thursday, December 13th, 2007

CHAPTER 20 WEB SERVICES 501 The soap_fault class also offers one method, serialize(). This function returns a complete SOAP message consisting of the fault information. Consider an example: $fault = new soap_fault(”Client”, “”, “Dollar value must be greater than 10!”, “”); $fault->serialize(); This returns the following: Client Dollar value must be greater than 10! Designating an HTTP Proxy If the client requires use of an HTTP proxy server, it can be set using the setHTTPProxy() method. This method takes two arguments, the proxy address and its port: $client = new soapclient(”http://www.example.com/boxing/server.php”, 80); $client->setHTTPproxy(”proxy.examplecompany.com”, 8080); All subsequent communication with the SOAP server initiated by this client will be routed through the designated proxy. Debugging Tools NuSOAP offers a debugging feature, which can be enabled on both the client and server sides. The method for enabling on each is identical, done by setting the debug_flag property to TRUE. For example: $client = new soapclient($endpoint); $client->debug_flag = true;
Check Tomcat Web Hosting services for best quality webspace to host your web application.

Web hosting directory - 500 CHAPTER 20 WEB SERVICES // Register

Wednesday, December 12th, 2007

500 CHAPTER 20 WEB SERVICES // Register the getRandQuote() function. $server->register(”getRandQuote”, array(’format’ => ‘xsd:string’), array(’return’ => ‘xsd:string’), ‘urn:boxing’, ‘urn:boxing#getRandQuote’); function getRandQuote() { $pg = pg_connect(”host=localhost user=jason password=secret dbname=corporate”); $query = “SELECT boxer, quote, year FROM quotation ORDER BY RAND() LIMIT 1″; $result = pg_query($query); $row = pg_fetch_array($result); $boxer = $row[”boxer”]; $quote = $row[”quote”]; $year = $row[”year”]; return “”$quote”, $boxer ($year)”; } $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ‘’; $server->service($HTTP_RAW_POST_DATA); ?> Fault Handling NuSOAP offers a class for handling errors that may occur during execution. This class, named soap_fault, has four attributes: faultactor: This optional attribute indicates which service caused the error. faultcode: This required attribute indicates the type of error. There are four possible values: Client, MustUnderstand, Server, and VersionMismatch. A Client error is returned when an error message is found within the message returned by the client. A MustUnderstand error occurs when a mandatory header has been found that is not understood. A Servererror occurs when a processing error has occurred on the server. Finally, a VersionMismatch error occurs when incompatible namespaces have been used. faultdetail: This optional attribute contains additional information about the error. faultstring: This required attribute contains an error description. These attributes are initialized via the class constructor, like so:
We recommend high quality webhost to host and run your jsp application: christian web host services.