Call WebService to view the QQ number status and webservice number

Source: Internet
Author: User
Tags soap client

Call WebService to view the QQ number status and webservice number

Call WebService to view the QQ number status

1.1. webService Service Interface

QQ online status WEB Service

Endpoint: http://webservice.webxml.com.cn/webservices/qqOnlineWebService.asmx

Disco: http://webservice.webxml.com.cn/webservices/qqOnlineWebService.asmx? Disco

WSDL: http://webservice.webxml.com.cn/webservices/qqOnlineWebService.asmx? Wsdl

Enter the QQ number (String) to check the online QQ status.

Returned data (String) Y = online; N = offline; E = QQ number error ......

1.2. Use Cases

1) create a java web project named qqws

2) switch to an empty directory on the cmd command line, enter the following command to download webservice

Wsimport-keep http://webservice.webxml.com.cn/webservices/qqOnlineWebService.asmx? Wsdl

Many files are added to the directory and all files are copied to the project.

3) Write Test. java

Package cn.com. webxml;

 

Public class Test {

 

Public static void main (String [] args ){

QqOnlineWebServiceSoap ws = new QqOnlineWebService ()

. GetPort (QqOnlineWebServiceSoap. class );

String qqqq = "1508787838 ";

 

String result = ws. qqCheckOnline (qq );

 

System. out. println (result );

 

// String, Y = online; N = offline; E = incorrect QQ number; A = Verification Failed for commercial users; V = the number of free users exceeds

If ("Y". equalsIgnoreCase (result )){

Result = "online ";

} Else if ("N". inclusignorecase (result )){

Result = "offline ";

} Else if ("E". cancsignorecase (result )){

Result = "Incorrect QQ number ";

} Else if ("A". cancsignorecase (result )){

Result = "commercial user verification failed ";

} Else if ("V". cancsignorecase (result )){

Result = "the number of free users has exceeded ";

}

 

System. out. println (result );

}

 

}

The running result is as follows:

Y

Online


How to call webservice

1. WebService calling in cs background program
A. Use the namespace and class name to directly call

Example:

WebService ws = new WebService ();

String s = ws. HelloWorld ();

B. Call by adding a WEB reference. First, add a WEB reference and use a URL to point to WEBSERVICE,

Specify the WEB reference name, which is assumed to be KK;

Example:

Kk. WebService n = new kk. WebService ();

String ss = n. HelloWorld ();

Ii. WebService JS call method on the front-end page

1. First, use the following method to reference Webservice in the foreground:

<Asp: ScriptManager runat = "server">
<Services>
<Asp: ServiceReference Path = "WebService. asmx" InlineScript = "True"/>
</Services>
</Asp: ScriptManager>

2. You can call the SDK through the JS program, for example:

<Script type = "text/jscript">
Function ()
{
WebService. HelloWorld (onresult );
}
// Here the onresult is the callback function
Function onresult (result)
{
Alert (result );
}
Function B ()
{
WebService. add (1, 2, onreturn)
}
Function onreturn (result)
{
Alert (result );
}
// The following 'context' is the context, which can be obtained by returning to the function through reloading;
Function c ()
{
WebService. div (1, 1, onresultC, onerror, 'context ');
}
Function onresultC (res, c)
{
Alert (res );
Alert (c );
}
// Onerror is the callback function used to obtain the exception information. The following describes how to obtain the exception information.
Function onerror (error)
{
Var a = "";
A = String. format ("Get server exception type: {0} \ t \ n get detailed exception description: {1} \ t \ n get cause exception: {2} \ t \ n gets the stack with an exception on the server.
Trace information: {3} \ t \ n gets a Boolean value, indicating whether the exception is caused by network connection timeout {4 }",
Error. get_exceptionType (),
Error. get_message (),
Error. get_statusCode (),
Error. get_stac... the remaining full text>

How to call WebService

That is to say, you can use a programming method to call this application through the Web. A more accurate explanation of Web services: Web services is a new platform for building interoperable distributed applications. As a Windows programmer, you may have created a component-based distributed application using COM or DCOM. COM is a very good component technology, but we can easily cite situations where COM does not meet the requirements. The Web service platform is a set of standards that define how applications implement interoperability on the Web. You can use any language you like to write Web Services on any platform you like, as long as we can query and access these services through the Web service Standard 2. after the basic concept of SOAP Web service is built, others will call it. Simple Object Access Protocol (SOAP) provides standard Remote Procedure Call (RPC) Methods to call Web Services. The SOAP specification defines the format of SOAP messages and how to use SOAP over Http. SOAP is also based on xml and XSD, and XML is the data encoding method of SOAP. The method call request and result return values between the client and the server are placed in these messages. XML and XSD Extensible Markup Language (XML) are basic formats for data representation on the Web service platform. In addition to ease of establishment and analysis, XML has the primary advantage of being platform-independent and vendor-independent. Independence is more important than technical superiority. XML solves the problem of data representation, but it does not define a set of standard data types, let alone how to extend this set of data types. For example, what is the integer number? 16-bit, 32-bit, or 64-bit? These details are important for implementing interoperability. XML Schema (XSD) developed by W3C is a set of standards dedicated to solving this problem. It defines a set of standard data types and provides a language to extend this data type. The Web service platform uses XSD as its data type system. When a Web service is constructed in a certain language (such as VB. NET or C #), all the data types used must be converted to the XSD type to comply with the Web service standard. 3. technical Features of Webservice: Cross-firewall communication if applications have thousands of users distributed around the world, communication between the client and the server will be a tough problem. Because there is usually a firewall or proxy server between the client and the server. In this case, using DCOM is not that simple, and usually it is not easy to publish the client program to every user with such a large number. The traditional approach is to use a browser as the client, write a lot of ASP pages, and expose the middle layer of the application to the end user. The result is that development is difficult and programs are difficult to maintain. For example, to add a new page to an application, you must first set up a user interface (Web page), which is followed by an intermediate layer component that contains the corresponding business logic, create at least one ASP page to accept user input, call the middle layer component, format the result as HTML, and then return the result page to the browser. If the client code is no longer so dependent on HTML forms, the client programming will be much simpler. If the intermediate layer component is changed to Web Service, you can directly call the intermediate layer component from the user interface, thus saving the step for creating an ASP page. To call a Web Service, you can directly use a SOAP client such as Microsoft SOAP Toolkit or. NET, or use a self-developed SOAP client to connect it to the application. This not only shortens the development cycle, but also reduces Code complexity and enhances the maintainability of applications. At the same time, the application does not need to jump to the corresponding "result page" every time it calls the middle layer components ". From the perspective of experience, using the Web Service structure in an application with more interaction between the user interface and the middle layer can save money on the user interface ...... remaining full text>

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.