Is web service a beautiful fairy tale?

Source: Internet
Author: User

After using Web Service for so many years, I believe no one will doubt its cross-platform nature. No matter whether it is Ms ws or J2EE WS, there is usually no configuration problem in the interaction between the user and the platform. However, when we want to use one platform to access ws of another platform, a conflict arises, that is, there are differences in wsml interpretation.

I made an example. In VB, mssoap is used to access the WS generated by PHP PEAR soap. As we all know, WSDL is generally not written by humans.

Suppose there is a function for sending short messages.

There are three main methods for PHP to generate a Web Service:

1. Use built-in soap Functions

Function send ($ address, $ content, $ key ){}

$ Server = new soapserver (null, array ('urn' => "smssender "));
$ Server-> addfunction ("send ");
$ Server-> handle ();

This method cannot generate the WSDL

2 Use pear's soap

Class smssender {
Function send ($ address, $ content, $ key ){
}
}

$ Server = new soap_server ();
$ WebService = new smssender ();
$ Server-> addobjectmap ($ WebService, 'urn: smssender ');
$ Server-> service ($ http_raw_post_data );

This class library can automatically generate the following WSDL:

Http://schemas.xmlsoap.org/wsdl/ "xmlns: Soap =" http://schemas.xmlsoap.org/wsdl/soap/ "xmlns: TNS =" urn: smssender "xmlns: XSD =" http://www.w3.org/2001/XMLSchema "xmlns: SOAP-ENC =" http://schemas.xmlsoap.org/soap/encoding/ "xmlns =" http://schemas.xmlsoap.org/wsdl/ ">
Http://schemas.xmlsoap.org/wsdl/>

Http://schemas.xmlsoap.org/soap/http "/>


Http: // 202.195.160.145/SMS/WS. php "/>

3. nusoap is used, but I am too lazy to use it because the latest version has bugs.

Next we use VB to call the second WS

Dim Client
Set Client = Createobject ("mssoap. soapclient30 ")
Client. clientproperty ("serverhttprequest") = true

On Error resume next

Call client. mssoapinit ("http: // host/SMS/WS. php? WSDL "," smssenderservice "," smssenderport ")
If err 0 then
Debug. Print "initialization failed" + err. Description
End if

Strg = client. Send ("12345678", "test", "key ")
If err 0 then
Debug. Print err. Description
Debug. Print "faultcode =" + client. faultcode
Debug. Print "faultstring =" + client. faultstring
Debug. Print "faultactor =" + client. faultactor
Debug. Print "detail =" + client. Detail
End if

Mssoap returns an error:

Initialization failedwsdlport: Port smssenderport has no operations hresult = 0x1: The function is incorrect.
-Wsdlservice: Processing Service smssenderservice found no port definitions hresult = 0x80070057: the parameter is incorrect.
-Wsdlreader: analyzing the WSDL file failed hresult = 0x80070057: the parameter is incorrect.
-Client: one of the parameters supplied is invalid. hresult = 0x80070057: the parameter is incorrect.

Is it true that the WSDL is incorrect? I continue to use the PHP PEAR soap client to call this WS

$ Client = new soap_client ("http: // host/SMS/WS. php ");
$ Client-> send ("12345677", "test", "key ");

I didn't even specify the WSDL, so it can be executed smoothly.

Also, if ws of axis are called to. net, there are often some inexplicable errors.

If I use a platform tool to generate the WSDL, and then let another platform use the WSDL to reverse generate the code, the readability of the code will be greatly reduced.

The crux of the problem seems to be the complexity of WSDL and the design at the beginning, without considering the convenience and feasibility of handwriting code, HTML is a completely handwriting code.

Is web servcie just like EJB, a so-called one-time deployment is just a beautiful fairy tale? Why can't various vendors make the WSDL completely neutral for their own benefit?

Or should there be a third-party tool that defines ws independently with tools in any language, and then automatically generates the configuration files required for various frameworks in various languages through customizable templates? If there is one, it may get angry!

Welcome to the discussion. What is your ws best practice?

 

I did not expect that this issue caused heated discussion by many friends. First, I declare that I chose the rest web service, because I think it is more convenient and convenient than soap in solving this problem. Secondly, I think the problem is that M $ did not find several PHP ws for testing when testing mssoap. Pear Soap also does not use mssoap for testing. Every vendor seems to have to ensure that their platform can be smoothly connected. This problem also exists for Axis and xfire. Like XHTML and CSS, although good, Each browser does not fully support all standards.

Trackback: http://tb.blog.csdn.net/TrackBack.aspx? Postid = 1799303

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.