How to quickly develop webservice client?
Write in front:
For the client, after the server is developed, the client only needs to call it. What we are talking about here is to generate the code needed by the client based on the access address of the service (I heard that there are several calling methods, but the most common one is the stub method, which seems to be the method I am talking about. , I haven’t studied it in depth. Haha, learn how to use it first)
1. Enter the access address of the service in the browser, such as: http://localhost:8080/test_axis3_stub/services/sayHello?wsdl, this step is In order to ensure that the service can be accessed normally.
2. Write a .bat file to generate java client code. You can choose the file name at will, and the content is as follows:
set Axis_Lib=D:\myEclipse10_WS\job\test_axis3_stub\WebRoot\WEB-INF\lib set Java_Cmd=java -Djava.ext.dirs=%Axis_Lib% set Output_Path=D:\my set Package=edu.hue.stub%Java_Cmd% org.apache.axis.wsdl.WSDL2Java -o%Output_Path% -p%Package% http://localhost:8080/test_axis3_stub/services/sayHello?wsdl
Here, copy and paste the above directly into your file, and then explain it a little bit, Axis_Lib: This is your axis.jar Storage path, generally for convenience, we just write the path of your project directly, all the way to lib, because your jar package is placed here; Output_Path: is the path to generate the java client code, You can just specify it yourself, for example, D:\my, provided that you have the folder my under your d drive; finally, just replace the access link address above with the link to the service you want to access, here is my It's http://localhost:8080/test_axis3_stub/services/sayHello?wsdl
That's it. Then double-click to run this .bat file to generate the java client code under D:\my (Note that your server should be running at this time), oh, by the way, maybe you are a novice like me and don’t even know how to create a .bat file. Let me briefly explain how you create a note After writing the content of this file, finally save it as my.bat. Note that you need to change the save type here to all files. Just save it afterwards. It becomes a .bat file.
3. Copy and paste the generated java client code into your project.
4. Create a client class with the following content:
package edu.hue.client;import java.rmi.RemoteException;import edu.hue.stub.SayHelloImpl;import edu.hue.stub.SayHelloImplService;import edu.hue.stub.SayHelloImplServiceLocator;public class MyClient {public static void main(String[] args) throws Exception {//获取服务集合SayHelloImplService service = new SayHelloImplServiceLocator();//获得服务SayHelloImpl client = service.getsayHello();//调用服务的方法 传递参数String result = client.say("臭小蚊子"); System.out.println(result); } }
The acquisition service collection here is new based on the java class you just generated. Pay attention to it. , generally this collection ends with Service, just new the class; to get the service, write directly. When you get the service, a prompt will appear. Choose which one of the prompts matches the service class you want to call. That's it; the subsequent method of calling the service is also written as client. After that, you can judge which method you want to call according to the prompts.
5. Right click and run. Success~~~~
Here are all about how to quickly use asix1.4 to develop a webservice. If it involves more complex parameter passing, for example, if the parameter passed is a bean, you need to study it yourself.
The above is the detailed content of How to quickly develop webservice client?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics
![VMware Horizon client freezes or stalls while connecting [Fix]](https://img.php.cn/upload/article/000/887/227/170942987315391.jpg?x-oss-process=image/resize,m_fill,h_207,w_330)
When connecting to a VDI using the VMWareHorizon client, we may encounter situations where the application freezes during authentication or the connection blocks. This article will explore this issue and provide ways to resolve this situation. When the VMWareHorizon client experiences freezing or connection issues, there are a few things you can do to resolve the issue. Fix VMWareHorizon client freezes or gets stuck while connecting If VMWareHorizon client freezes or fails to connect on Windows 11/10, do the below mentioned solutions: Check network connection Restart Horizon client Check Horizon server status Clear client cache Fix Ho

This AI-assisted programming tool has unearthed a large number of useful AI-assisted programming tools in this stage of rapid AI development. AI-assisted programming tools can improve development efficiency, improve code quality, and reduce bug rates. They are important assistants in the modern software development process. Today Dayao will share with you 4 AI-assisted programming tools (and all support C# language). I hope it will be helpful to everyone. https://github.com/YSGStudyHards/DotNetGuide1.GitHubCopilotGitHubCopilot is an AI coding assistant that helps you write code faster and with less effort, so you can focus more on problem solving and collaboration. Git

MQTT (MessageQueuingTelemetryTransport) is a lightweight message transmission protocol commonly used for communication between IoT devices. PHP is a commonly used server-side programming language that can be used to develop MQTT clients. This article will introduce how to use PHP to develop an MQTT client and include the following content: Basic concepts of the MQTT protocol Selection and usage examples of the PHPMQTT client library: Using the PHPMQTT client to publish and

On March 3, 2022, less than a month after the birth of the world's first AI programmer Devin, the NLP team of Princeton University developed an open source AI programmer SWE-agent. It leverages the GPT-4 model to automatically resolve issues in GitHub repositories. SWE-agent's performance on the SWE-bench test set is similar to Devin, taking an average of 93 seconds and solving 12.29% of the problems. By interacting with a dedicated terminal, SWE-agent can open and search file contents, use automatic syntax checking, edit specific lines, and write and execute tests. (Note: The above content is a slight adjustment of the original content, but the key information in the original text is retained and does not exceed the specified word limit.) SWE-A

Go language development mobile application tutorial As the mobile application market continues to boom, more and more developers are beginning to explore how to use Go language to develop mobile applications. As a simple and efficient programming language, Go language has also shown strong potential in mobile application development. This article will introduce in detail how to use Go language to develop mobile applications, and attach specific code examples to help readers get started quickly and start developing their own mobile applications. 1. Preparation Before starting, we need to prepare the development environment and tools. head

When many friends download files, they will first browse on the web page and then transfer to the client to download. But sometimes users will encounter the problem that the Baidu Netdisk webpage cannot start the client. In response to this problem, the editor has prepared a solution for you to solve the problem that the Baidu Netdisk webpage cannot start the client. Friends in need can refer to it. Solution: 1. Maybe Baidu Netdisk is not the latest version. Manually open the Baidu Netdisk client, click the settings button in the upper right corner, and then click version upgrade. If there is no update, the following prompt will appear. If there is an update, please follow the prompts to update. 2. The detection service program of Baidu Cloud Disk may be disabled. It is possible that we manually or use security software to automatically disable the detection service program of Baidu Cloud Disk. Please check it out

What is the difference in the "My Computer" path in Win11? Quick way to find it! As the Windows system is constantly updated, the latest Windows 11 system also brings some new changes and functions. One of the common problems is that users cannot find the path to "My Computer" in Win11 system. This was usually a simple operation in previous Windows systems. This article will introduce how the paths of "My Computer" are different in Win11 system, and how to quickly find them. In Windows1

WordPress Website Building Guide: Quickly Build a Personal Website With the advent of the digital age, having a personal website has become fashionable and necessary. As the most popular website building tool, WordPress makes it easier and more convenient to build a personal website. This article will provide you with a guide to quickly build a personal website, including specific code examples. I hope it can help friends who want to have their own website. Step 1: Purchase a domain name and hosting. Before starting to build a personal website, you must first purchase your own
