Visual Studio/eclipse calls the webservice in JBOSS5

Source: Internet
Author: User
Tags jboss

1. Hellowebservice.java

Package Com.xx.webservices;import Javax.jws.webmethod;import Javax.jws.webparam;import javax.jws.WebResult;import Javax.jws.WebService; @WebServicepublic class Hellowebservice {@WebMethod @webresult (name= "result") public String SayHello (@WebParam (name= "name") String name) {System.out.println ("SayHello:" + name); return "Hello, JBoss5 WebService welcome you: ["+ name +"] ";} @WebMethod @webresult (name= "result") public int Add (@WebParam (name= "a") int A, @WebParam (name= "b") int b) {return a + B;}}

2. Web. xml

<servlet><servlet-name>Hello</servlet-name><servlet-class> com.xx.webservices.hellowebservice</servlet-class></servlet><servlet-mapping>< Servlet-name>hello</servlet-name><url-pattern>/hello</url-pattern></servlet-mapping >

3. Vs Add WebService Reference, Progam.cs

Using system;using system.collections.generic;using system.linq;using system.text;namespace HelloJBossService{    Class program    {        static void Main (string[] args)        {            jbosshelloserviceref.hellowebserviceclient client = new Jbosshelloserviceref.hellowebserviceclient ();            Jbosshelloserviceref.add Reqadd = new Jbosshelloserviceref.add ();            REQADD.A = -11;            REQADD.B =;            var rspadd = Client.add (reqadd);            var ret = Rspadd.result;            Console.WriteLine (ret);            for (int i = 0; i < i++)            //{                Jbosshelloserviceref.sayhello reqsay = new Jbosshelloserviceref.sayhello () ;                Reqsay.name = "Zhang San";                var Rspsay = Client.sayhello (Reqsay);                Console.WriteLine (Rspsay.result);            }            Console.readkey ();}}    }

Java Side Call Method:

1. In the ${jboss_home}/bin directory, execute in cmd:

d:\devprograms\jboss\jboss-5.1.0.ga\bin>wsconsume.bat-k http://localhost:8080/HelloWorldJBoss5/hello?wsdl

Generate proxy files.

2. Copying to a Java project

3. Add test Code

public class Testmain {/** * @param args */public static void main (string[] args) {Hellowebserviceservice svcproxy = new H Ellowebserviceservice (); Hellowebservice svc = Svcproxy.gethellowebserviceport (); int c = Svc.add (11, 22); System.out.println (c); String ret = Svc.sayhello ("Wu xx11"); SYSTEM.OUT.PRINTLN (ret);}}

  

Visual Studio/eclipse calls the webservice in JBOSS5

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.