Php and java combination

Source: Internet
Author: User
The combination of php and java has recently rolled up the e-commerce boom in the small city where you are located. there are more and more e-commerce website companies, basically in the php + java mode. I have been using JAVA for development before, and I want to find out how to implement the combination of php and java. I checked online materials. There are three methods to achieve this: WebService (SOAP), Quercus, and the combination of ph php and java
Recently, my own small City rolled up the e-commerce boom. more and more e-commerce website companies are basically using php + java. I have been using JAVA for development, and I want to find out how to integrate php with java.

I checked the information on the Internet and generally implemented the following methods: WebService (SOAP), Quercus, and php-java bridge.

I tried the first two methods in the past few days. Record the process by the way

1. WebService (SOAP)
1. First of all, it is of course to publish a WebService service.
Take the previous numeric calculation as an example.
Package rong. service;

Public class CalculateService {

Public in plus (int ){
Return a + 1;
}
}

2. release aar to Tomcat's axis2 (for details, refer to my andorid to connect to WebService)
3. access through php (first make sure php-soap is set in php. ini)
$ Wsdl = "http: // localhost: 8080/axis2/service/CalculateService ";
$ Client = new SoapClient ($ wsdl );

// Set parameters
$ Params = array ("param0" => "1 ");
// Print the result
Echo $ response-> return;
?>


II. Method 2 Quercus

1. in fact, you only need to download a resin file with Quercus, because it already contains Quercus.
Directly store the php file in the ROOT of Webapps, and you can directly call the JAVA class.
For example:
Import rong. service .*;
$ JavaObj = new CalculateService ();
Echo $ javaObj-> plus (1 );
?>

2. to run php in Tomcat can also, http://quercus.caucho.com/download the Quercus. war File, throwing it to Tomcat, and then the above method is the same. War contains several jar files required to run php.

Summary:
According to the information, the performance of WebService is relatively poor in general, because to do cross-platform, XML needs DOM parsing, which consumes a lot of memory. In the words of netizens, HTTP protocol penetration is relatively simple and is very popular. However, the disadvantage is that it is slow.

The query speed is good. on the Internet, the test execution of php in Quercus is about 4 times faster than the original one. after all, it is thrown into the Servlet. it is the first time the execution is full, and then it will be fine. The disadvantage is that it will occupy virtual machine resources.


Please correct the incorrect content.

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.