Eclipse中新增SOAP WebService操作后如何更新WSDL
Hey there! Let's walk through exactly how to get your new addCI operation showing up in your WSDL, since you already have sayHello working smoothly. Here's the step-by-step breakdown:
1. Update Your WebService Code First
Before touching the WSDL, you need to add the new operation to your service's interface and implementation:
- Open your WebService interface (e.g.,
YourService.java) and add theaddCImethod definition with proper JAX-WS annotations:@WebMethod(operationName = "addCI") @WebResult(name = "addCIResult") public int addCI(@WebParam(name = "param1") int num1, @WebParam(name = "param2") int num2); - Implement this method in your service's concrete class (e.g.,
YourServiceImpl.java) with your business logic.
2. Regenerate/Update the WSDL in Eclipse
Eclipse's JAX-WS tools handle WSDL generation automatically based on your annotated code—you just need to trigger the update:
- Right-click your WebService project → Go to
Web Services→ SelectUpdate Web Service. - In the popup dialog:
- Make sure the
Service Implementationpoints to your updated service class. - Check the
Generate WSDLoption (this overwrites or updates the existing WSDL with your new operation). - Click
Finish—Eclipse will generate the updated WSDL that includes bothsayHelloandaddCI.
- Make sure the
For Dynamic WSDL (Accessed via ?wsdl)
If your service uses a dynamically generated WSDL (the one you get by appending ?wsdl to your service URL), you just need to:
- Restart your application server (e.g., Tomcat, WildFly). The server will pick up the updated service code and generate a fresh WSDL with the
addCIoperation when you access the URL.
3. Verify the Updated WSDL
Open your browser and navigate to your service's WSDL URL. Search for addCI—you should see:
- An
<operation>entry under the<portType>section. - Corresponding
<message>definitions for the request and response ofaddCI. - The
<binding>section mapping the operation to SOAP.
4. Update Your Client (If Needed)
If you have an existing client generated from the old WSDL, you'll need to regenerate it to access the new addCI operation:
- Right-click your client project →
Web Services→Generate Client. - Input the updated WSDL URL and follow the prompts to regenerate the client classes. Now you can call
addCIjust like you do withsayHello.
Quick Notes to Avoid Issues
- Double-check that your
addCImethod has all required JAX-WS annotations—missing annotations can cause the operation to not show up in the WSDL. - If you're using a framework like Apache CXF, ensure your service configuration (e.g.,
cxf-servlet.xml) doesn't hardcode a static WSDL path; use dynamic generation instead. - Always restart your server after code changes to clear any cached WSDL content.
内容的提问来源于stack exchange,提问作者lrente

