- 浏览: 80301 次
文章分类
- 全部博客 (89)
- web service (9)
- subversion (1)
- JBOSS (3)
- interview (23)
- jQery (2)
- ExtJs (0)
- Axis (0)
- Design pattern (3)
- Agile (2)
- mutithread (0)
- Core Java (24)
- programming methods (1)
- SSH (7)
- jee design (1)
- OO (4)
- books (8)
- other (1)
- JSF (7)
- seam (2)
- Weblogic (4)
- JPA (1)
- ADF (1)
- Spring (5)
- Tomcat (1)
- DWR (2)
- JEE (3)
- Servlet (1)
- EJB (1)
- JDBC (3)
最新评论
-
iloveflower:
呵呵。好好学习。。。。。。。。。。。。
java 读书 -
Eric.Yan:
看了一点,不过是电子版的……你这一说到提醒我了,还要继续学习哈 ...
java 读书
http://www.coderanch.com/t/543976/Web-Services/java/Steps-creating-Remote-Java-WebServices
Configuring JBoss:
1.) To run JBoss through eclipse, simply add it to the servers.
2.) To run JBoss on local host (explorer), go to JBoss folder, then bin, and then simply run the Run.bat file. By default it runs on Port 8080. So make sure that this port is free for jboss to run.
3.) By default if you run the JBoss, it will run only on local host, but you cannot run it through remote system. To run it through remote system, you have to run the Run.bat with some arguments. Make another bat file in the same location, say mybat.bat. now edit this mybat.bat and write these lines in it:
Run.bat –b 0.0.0.0
After that you can run the JBoss through your mybat.bat file instead of running it through Run.bat. The arguments 0.0.0.0 are the address of the remote user. Giving it in this (0.0.0.0) format means anybody can run your jboss on his/her system. If you specifically want to give the address of remote user, than you can give the address of remote user in place of 0.0.0.0 (i.e. say 192.168.0.9 instead of 0.0.0.0).
4.) Before going ahead, please make sure that jboss is working fine at your local as well as through remote system.
JDK and API’s Required for running jboss on eclipse
1.) Make sure that you are using jre 1.6.0.17 or higher version and you have the required API’s (axis.jar, commons-discovery-0.2.jar, commons-logging.jar, jaxb-api.jar, jaxrpc.jar, saaj.jar, wsdl4j.jar).
2.) Configure the jboss in eclipse properly.
Creating Web Services has two parts. First is creating Web Service and second is creating WebService Client.
Creating WebService in eclipse:
1.) First create a new dynamic web project say Project1.
2.) Now create a package say pkg in src folder and create a class say Addition.java. This class will be having the methods which the user wants to access remotely. This class is also known as Endpoint.
3.) Now define a method in this class, say a method named addNumbers(int x,int y) which simply returns the addition of these two parameters.
4.) After creation of the class, right click on the class, go to web services, click on the create web service. Now we will be creating a WebService i.e. our first step.
5.) Now a window will appear, now in the first column named Web service type, select Bottom up java bean Services. In the second column named Service implementation, give the package name and your Endpoint class name i.e. pkg.Addition.
6.) On the below of these two columns, select start service from the chooser bar and select No client from the bar below this. Give java Proxy in the client type.
7.) Now click Finish button. Now it will first start the jboss if not started.
8.) After the end of this process, it will create a wsdl folder inside the WebContent of the same project. Inside the wsdl folder, there is an xml file. Which is named like Endpoint.wsdl i.e. Addition.wsdl.
9.) Now first of all you should be able to run this xml file through jboss inside eclipse as well as outside the eclipse(i.e. on the explorer). To run it through eclipse, simply right click on the xml file and select option run on server. It will run the xml file in your browser inside eclipse. Now you can use the same url to run this xml on the explorer outside eclipse.
10.) Remember one thing, jboss cannot run its two instances i.e. in eclipse as well as outside(through Run.bat) simultaneously. So you have to stop the jboss from inside the eclipse to run it outside. Otherwise it will through exception that port is already in use.
11.) If you want to run jboss from remote address, then start jboss through mybat.bat created by our self instead of Run.bat.
Creating WebService Client:
Now we can create a WebService client to call the Endpoint class generated.
1.) Create another dynamic java project say Project1Client. It will act as a client for our Project1 project to receive methods.
2.) Now select the project, go to file, new and select others. Now select Webservice Client inside WebServices.
3.) Now when you select this option, a window will appear. Now in the service definition give the url of the wsdl xml i.e. address of Addition.wsdl which you have run last time. Url will look like http://localhost:8080/Project1/wsdl/Addition.wsdl.
4.) Note that if you want to access this web service on remote site, then give here proper address of the server system(ip of your system here) i.e. http://192.168.0.62:8080/Project1/wsdl/Addition.wsdl for example. but before giving this proper ip address, make sure that your Jboss in running from outside the eclipse and you are able to run this url from your or from remote system. If the Jboss is not running from outside, it will show error that “service definition selected is invalid”. If you are going for your localhost, then no need to run jboss from outside. Then it will also work if your jboss is started inside the eclipse.
5.) Now from below bar, select the “start client” option.
6.) Now click next button.
7.) Now if you have given the remote ip address in the service definition, then after the next button click, you have to stop the jboss from outside. Now click on next button and then select start server. It will start jboss inside the eclipse.
8.) Stopping jboss outside in necessary after first step, because if you don’t stop it, you will not be able to run jboss inside your eclipse.
9.) Now after everything completes without any exception, you will see a package created in your src in your this project(Project1Client). i.e package name pkg, the same package name you have given in the Project1.
10.) There would be some classes in this package i.e. one is having same name as your endpoint i.e. Addition.java, AdditionProxy.java, AdditionService.java, AdditionServiceLocator.java, AdditionSoapBindingStub.java. These are the classes which are automatically created in your WebService client project.
11.) Now the AdditionProxy.java is the class which you will be using to access your methods remotely.
12.) Now make a new class in the same package in your client project say Myclass.java.
13.) Now in this class you can call the object of proxy class i.e. AdditionProxy.java.
Say for example: AdditionProxy object =new AdditionProxy();
Int result=object.addNumbers(2,3);
System.out.println(“Addition of two numbers:”+result);
14.) When you will run this class with code something like this, it will show you the output as the addition of two numbers 2 and 3.
15.) If you are running this class on the same system, then make sure that jboss is running inside your eclipse.
16.) If you want to see the result on remote system, then simply copy whole package i.e. pkg and copy it on some remote system in any project. Also add the API’s to project if required.
17.) Now before running it on remote system, you need to do one change in the AdditionServiceLocator.java. there is mentioned the address of your server system in the variable Addition_address variable. By default, there is given a local system address. Change it and give the ip address of your server system instead of localsystem.
18.) Now you can run Myclass.java to see the output, but before running make sure the your jboss in running (outside eclipse through the mybat.bat file) on the server system.
19.) Now when you will run this class, you can see this output :
Addition of two numbers:5
Configuring JBoss:
1.) To run JBoss through eclipse, simply add it to the servers.
2.) To run JBoss on local host (explorer), go to JBoss folder, then bin, and then simply run the Run.bat file. By default it runs on Port 8080. So make sure that this port is free for jboss to run.
3.) By default if you run the JBoss, it will run only on local host, but you cannot run it through remote system. To run it through remote system, you have to run the Run.bat with some arguments. Make another bat file in the same location, say mybat.bat. now edit this mybat.bat and write these lines in it:
Run.bat –b 0.0.0.0
After that you can run the JBoss through your mybat.bat file instead of running it through Run.bat. The arguments 0.0.0.0 are the address of the remote user. Giving it in this (0.0.0.0) format means anybody can run your jboss on his/her system. If you specifically want to give the address of remote user, than you can give the address of remote user in place of 0.0.0.0 (i.e. say 192.168.0.9 instead of 0.0.0.0).
4.) Before going ahead, please make sure that jboss is working fine at your local as well as through remote system.
JDK and API’s Required for running jboss on eclipse
1.) Make sure that you are using jre 1.6.0.17 or higher version and you have the required API’s (axis.jar, commons-discovery-0.2.jar, commons-logging.jar, jaxb-api.jar, jaxrpc.jar, saaj.jar, wsdl4j.jar).
2.) Configure the jboss in eclipse properly.
Creating Web Services has two parts. First is creating Web Service and second is creating WebService Client.
Creating WebService in eclipse:
1.) First create a new dynamic web project say Project1.
2.) Now create a package say pkg in src folder and create a class say Addition.java. This class will be having the methods which the user wants to access remotely. This class is also known as Endpoint.
3.) Now define a method in this class, say a method named addNumbers(int x,int y) which simply returns the addition of these two parameters.
4.) After creation of the class, right click on the class, go to web services, click on the create web service. Now we will be creating a WebService i.e. our first step.
5.) Now a window will appear, now in the first column named Web service type, select Bottom up java bean Services. In the second column named Service implementation, give the package name and your Endpoint class name i.e. pkg.Addition.
6.) On the below of these two columns, select start service from the chooser bar and select No client from the bar below this. Give java Proxy in the client type.
7.) Now click Finish button. Now it will first start the jboss if not started.
8.) After the end of this process, it will create a wsdl folder inside the WebContent of the same project. Inside the wsdl folder, there is an xml file. Which is named like Endpoint.wsdl i.e. Addition.wsdl.
9.) Now first of all you should be able to run this xml file through jboss inside eclipse as well as outside the eclipse(i.e. on the explorer). To run it through eclipse, simply right click on the xml file and select option run on server. It will run the xml file in your browser inside eclipse. Now you can use the same url to run this xml on the explorer outside eclipse.
10.) Remember one thing, jboss cannot run its two instances i.e. in eclipse as well as outside(through Run.bat) simultaneously. So you have to stop the jboss from inside the eclipse to run it outside. Otherwise it will through exception that port is already in use.
11.) If you want to run jboss from remote address, then start jboss through mybat.bat created by our self instead of Run.bat.
Creating WebService Client:
Now we can create a WebService client to call the Endpoint class generated.
1.) Create another dynamic java project say Project1Client. It will act as a client for our Project1 project to receive methods.
2.) Now select the project, go to file, new and select others. Now select Webservice Client inside WebServices.
3.) Now when you select this option, a window will appear. Now in the service definition give the url of the wsdl xml i.e. address of Addition.wsdl which you have run last time. Url will look like http://localhost:8080/Project1/wsdl/Addition.wsdl.
4.) Note that if you want to access this web service on remote site, then give here proper address of the server system(ip of your system here) i.e. http://192.168.0.62:8080/Project1/wsdl/Addition.wsdl for example. but before giving this proper ip address, make sure that your Jboss in running from outside the eclipse and you are able to run this url from your or from remote system. If the Jboss is not running from outside, it will show error that “service definition selected is invalid”. If you are going for your localhost, then no need to run jboss from outside. Then it will also work if your jboss is started inside the eclipse.
5.) Now from below bar, select the “start client” option.
6.) Now click next button.
7.) Now if you have given the remote ip address in the service definition, then after the next button click, you have to stop the jboss from outside. Now click on next button and then select start server. It will start jboss inside the eclipse.
8.) Stopping jboss outside in necessary after first step, because if you don’t stop it, you will not be able to run jboss inside your eclipse.
9.) Now after everything completes without any exception, you will see a package created in your src in your this project(Project1Client). i.e package name pkg, the same package name you have given in the Project1.
10.) There would be some classes in this package i.e. one is having same name as your endpoint i.e. Addition.java, AdditionProxy.java, AdditionService.java, AdditionServiceLocator.java, AdditionSoapBindingStub.java. These are the classes which are automatically created in your WebService client project.
11.) Now the AdditionProxy.java is the class which you will be using to access your methods remotely.
12.) Now make a new class in the same package in your client project say Myclass.java.
13.) Now in this class you can call the object of proxy class i.e. AdditionProxy.java.
Say for example: AdditionProxy object =new AdditionProxy();
Int result=object.addNumbers(2,3);
System.out.println(“Addition of two numbers:”+result);
14.) When you will run this class with code something like this, it will show you the output as the addition of two numbers 2 and 3.
15.) If you are running this class on the same system, then make sure that jboss is running inside your eclipse.
16.) If you want to see the result on remote system, then simply copy whole package i.e. pkg and copy it on some remote system in any project. Also add the API’s to project if required.
17.) Now before running it on remote system, you need to do one change in the AdditionServiceLocator.java. there is mentioned the address of your server system in the variable Addition_address variable. By default, there is given a local system address. Change it and give the ip address of your server system instead of localsystem.
18.) Now you can run Myclass.java to see the output, but before running make sure the your jboss in running (outside eclipse through the mybat.bat file) on the server system.
19.) Now when you will run this class, you can see this output :
Addition of two numbers:5
发表评论
-
SOAPBind style区别
2012-04-18 03:57 1165翻译自 The Difference Between RPC ... -
web service
2012-04-18 03:09 02001_Programming Web Services w ... -
Sample on JAXB using Eclipse
2012-03-06 05:49 0Java Architecture for XML Bindi ... -
Java Web Services Developer's Pack, v2.0
2012-03-06 00:02 0For Java Web Services Developer ... -
开发 web 服务常用模式
2012-03-02 05:55 784Web 服务提示与技巧: JAX-RPC 与 JAX-WS 的 ... -
SOAP1.1 SOAP1.2 or simple http sample
2012-03-02 04:48 1601SOAP 1.1 The following is a sam ... -
WSDL sample(the weathernetwork)
2012-03-02 04:38 817WSDL 文档在Web服务的定义中使用下列元素: ... -
web service introduce
2012-03-02 04:33 864Web Services Introduction Befo ... -
REST Web Service Interview Questions
2012-03-02 00:49 1025Here I am putting 20 REST quest ... -
Axis与CXF比较
2012-03-01 06:32 1025新一代的 Web Services 框架如 Axis2、CXF ... -
web service相关简介
2012-03-01 05:35 8141.WEBSERVICE简介 2.WebService之AX ...
相关推荐
Animated Storytelling Simple Steps For Creating Animation and Motion Graphics 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书
Java in easy steps, 6th edition instructs you how to easily create your own exciting Java programs. Updated for Java 9, which was released September 2017, it contains separate chapters on the major ...
Animated Storytelling Simple Steps For Creating Animation and Motion Graphics 英文azw3 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书
Animated Storytelling Simple Steps For Creating Animation and Motion Graphics 英文无水印转化版pdf pdf所有页面使用FoxitReader、PDF-XChangeViewer、SumatraPDF和Firefox测试都可以打开 本资源转载自网络...
Building RESTful Web Services with Spring 5 – Second Edition: Leverage the power of Spring 5.0, Java SE 9, and Spring Boot 2.0 Find out how to implement the REST architecture to build resilient ...
Beginning Amazon Web Services with Node.js teaches any novice Node.js developer to configure, deploy, and maintain scalable small to large scale Node.js applications in Amazon Web Services. Hosting a ...
### Eclipse in Action: A Comprehensive Guide for Web Developers #### Chapter Overview and Context The book titled "Eclipse in Action" provides a detailed guide for web developers on how to ...
《Java in easy steps》涵盖了Java 9,并特别针对Java 8的新特性进行了详细讲解。其中,“Lambda”作为核心知识点之一,代表了Java语言在现代编程范式中的一大步。 Lambda表达式是一种可以传递给方法或存储在变量中...
Creating Web Pages AIO Desk Reference 2nd Ed For Dummies.pdf Creating Web Pages AIO Desk Reference 3rd Ed For Dummies.pdf Creating Web Pages For Dummies 7ed.pdf Creating Web Pages For Dummies 8th Ed ...
Python in easy steps, 2nd edition makes no assumption you have previous knowledge of any programming language so it’s ideal for the newcomer to computer programming. It has an easy-to-follow style ...
Steps for creating a C# program New capabilities of C# 5.0 An introduction to object-oriented programming Important advice on writing secure code Alternatives to using Visual Studio Why Windows ...
In conclusion, writing a manuscript for RemoteSensing journal requires a well-structured approach, with attention to detail in the research design, methodology, analysis, and presentation of results....
R for Data Analysis in easy steps begins by explaining core programming principles of the R programming language, which stores data in “vectors” from which simple graphs can be plotted. Next, the ...
It is appropriate both for computer science undergraduate graphics programming courses in degree programs that emphasize Java, and for professionals interested in mastering 3D graphics skills who ...
《Restlet Edition for Java SE初探:开启RESTful之旅》 在Java开发领域,当我们谈论RESTful服务时,经常会提到一个强大的工具——Restlet。它是一个完全基于Java的开源框架,专为构建REST(Representational State...
Chapter 1: Our First Steps in Java Regular Expressions Chapter 2: Basic Characters Used in Regex Chapter 3: Java Regex Classes Chapter 4: Regex for Username Chapter 5: Regex for Password Chapter 6: ...
In the dynamic world of web development, especially in the realms of Flash and Flex, the integration between Eclipse and Flex Builder has been a significant step forward. This article delves into the ...
Eclipse是一款强大的开源集成开发环境(IDE),主要用于Java应用程序的开发,但通过各种插件,它也可以支持C/C++、Python、Web应用等多种编程语言的开发。本指南将深入探讨Eclipse的基本操作、项目管理、代码编辑、...