Question about jre6 WebService calling using PHP class library nusoap

Source: Internet
Author: User

Jre6.0 has added support for WebService and does not need to use open-source class libraries.

Take a lookCode:

 

 
@ WebService (name = "testws", servicename = "testws ") public class testws {/*** test the addition method * @ Param x * @ Param y * @ return */@ webmethodpublic int testmethod (int x, int y) {return x + y ;}}
 
/*** @ Author v. xieping **/public class program {/*** @ Param ARGs */public static void main (string [] ARGs) {endpoint. publish ("http: // 192.168.53.43: 8090/cseventws/testws", new testws (); threadwaitor. keepwait ();}}

 

Use this method

 
Http:/// 192.168.53.43: 8090/cseventws/testws
 
This address can access this WebService.
 
 
 
However, the strange problem is that I am a nusoap class library and cannot be called as before. Three problems were found in the test.
1. WSDL Problems
But use the address
 
Http:/// 192.168.53.43: 8090/cseventws/testws
 
Or address
 
Http: // 192.168.53.43: 8090/cseventws/testws? WSDL
 
When a nusoap object is created, it cannot be considered as a WSDL object. That is to say, both addresses are non-WSDL addresses.
 
 
 
2. namespace Problems
 
As we all know, the namespace used in development is "http://tempuri.org/", but not here, it becomes http://ws.csevent /.
Available
 
Http: // 192.168.53.43: 8090/cseventws/testws? WSDL
 
View such address <definitions targetnamespace = "http://ws.csevent/" name = "testws">
 
 

3. Parameter Problems

Generally, the parameters of the WSDL address are related to the name. But it is not here.

$ Params = array ('arg0' => 100, 'arg1' => 200 );

This method is defined.

 

You can useHttp: // 192.168.53.43: 8090/cseventws/testws? View WSDL

 

<Types> − <XSD: schema> <XSD: Import namespace = "http://ws.csevent/" schemalocation = "http: // 192.168.53.43: 8090/cseventws/testws? XSD = 1 "/> </XSD: schema> </types>

<Types>

− <XSD: schema>

<XSD: Import namespace = "http://ws.csevent /"

Schemalocation = "http: // 192.168.53.43: 8090/cseventws/testws? XSD = 1 "/>

</XSD: schema>

</Types>

Start http: // 192.168.53.43: 8090/cseventws/testws? The parameter name is displayed after XSD = 1.

 

<Xs: complextype name = "testmethod">

<Xs: sequence>

<Xs: element name = "arg0" type = "XS: int"/>

<Xs: element name = "arg1" type = "XS: int"/>

</Xs: sequence>

</Xs: complextype>

 

The final call is:

Note: The following code uses the slightphp framework. Implements the preliminary packaging of nusoap.

$ Objsoap = new http_soap ();

$ Client = $ objsoap-> getclient ($ this-> URL, false );

$ Params = array ('arg0' => 100, 'arg1' => 200 );

$ R = $ client-> call ('testmethod', $ Params, 'HTTP: // ws. csevent/', '', false, true );

Debug_util: log ($ R, "service. log ");

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.