Use PHP soap extensions for wdsl operations

Source: Internet
Author: User
Tags microsoft iis
This article is an example of using phpsoap to access webservice. for the wsdl file, see www.webxml.com.cn. there are many useful servers. most of them are free of charge. take simplified and Traditional Chinese as an example. the simplified and traditional wsdl file address is webservice.webxml.com. cnWebServices

This article is an example of using php soap to access webservice. for the wsdl file, see http://www.webxml.com.cn. there are many useful servers. most of them are free of charge. take simplified and Traditional Chinese as an example. simplified conversion wsdl file address: http://webservice.webxml.com.cn/WebServices


This article is an example of using php soap to access webservice.

For the wsdl file, see http://www.webxml.com.cn/this website. There are a lot of useful servers.

Most of them are free of charge.


Take simplified and Traditional Chinese as an example.


Simplified conversion wsdl file address: http://webservice.webxml.com.cn/WebServices/TraditionalSimplifiedWebService.asmx? Wsdl

The following describes the PHP code.


 _ GetFunctions (); // This is the service that this interface can provide, that is, the function definition. It has parameters and the return value var_dump ($ soap->__ getTypes ()); // This is the data type used by this interface.

The returned values are as follows:

Function Declaration

array (size=4)  0 => string 'toSimplifiedChineseResponse toSimplifiedChinese(toSimplifiedChinese $parameters)' (length=80)  1 => string 'toTraditionalChineseResponse toTraditionalChinese(toTraditionalChinese $parameters)' (length=83)  2 => string 'toSimplifiedChineseResponse toSimplifiedChinese(toSimplifiedChinese $parameters)' (length=80)  3 => string 'toTraditionalChineseResponse toTraditionalChinese(toTraditionalChinese $parameters)' (length=83)
 

Type Definition

array (size=4)  0 => string 'struct toSimplifiedChinese { string sText;}' (length=45)  1 => string 'struct toSimplifiedChineseResponse { string toSimplifiedChineseResult;}' (length=73)  2 => string 'struct toTraditionalChinese { string sText;}' (length=46)  3 => string 'struct toTraditionalChineseResponse { string toTraditionalChineseResult;}' (length=75)

From this output, we can see that,

toTraditionalChineseResponse toTraditionalChinese(toTraditionalChinese $parameters)

This is a function for converting simplified to traditional.

ToTraditionalChinese

Structure:

struct toTraditionalChinese { string sText;}

Corresponds to PHP, which is an array with sText as the key and value as the string,

For example, array ('stext '=>' to convert to a traditional Chinese character ')

The return value of this function is:

struct toTraditionalChineseResponse { string toTraditionalChineseResult;}

This is for PHP. A stdClass has an attribute called toTraditionalChineseResult.

The following is a PHP code with a complete return value, which contains the xml Information sent and the xml Information received.

 True); // call this function directly, because in this object, all functions start with a double underline, so there is no conflict. $ rs = $ soap-> toTraditionalChinese (array ('stext '=>' I want to convert to traditional Chinese, long'); // display the converted value, stdClass object. var_dump ($ rs); // display the converted content, string echo $ rs-> toTraditionalChineseResult; echo'
 The following are sending and receiving information'; // send HTTP header var_dump ($ soap->__ getLastRequestHeaders (); // send HTTP_BODYvar_dump ($ soap->__ getLastRequest ()); // received HTTP header var_dump ($ soap->__ getLastResponseHeaders (); // received HTTP_BODYvar_dump ($ soap->__ getLastResponse ());

The returned values in the preceding example are as follows:

Object (stdClass) [2]
Public 'totraditionalchineseresult '=> string' I want to compile it into a traditional Chinese, please '(length = 26)
I want to make it traditional.
Send and receive information
String 'Post/WebServices/TraditionalSimplifiedWebService. asmx HTTP/1.1
Host: webservice.webxml.com.cn
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.3.13
Content-Type: text/xml; charset = UTF-8
SOAPAction: "http://webxml.com.cn/toTraditionalChinese"
Content-Length: 305


'(Length = 269)
String'
I want to convert it to traditional Chinese, Dragon
'(Length = 305)
String 'HTTP/1.1 200 OK
Date: Thu, 17 Jul 2014 08:55:43 GMT
Server: Microsoft-Microsoft IIS/6.0
X-Powered-By: ASP. NET
X-AspNet-Version: 2.0.50727
Cache-Control: private, max-age = 0
Content-Type: text/xml; charset = UTF-8
Content-Length: 420
'(Length = 228)
String' I want to make it traditional. '(Length = 420)


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.