# How Do I: Use a Web Service that Is in Another Project?

The short answer is: you shouldn't. If you find you want to invoke a web service that is in the same application, it probably means you have placed business logic in that web service that should really be in a Java control.

To use another web service, you would use a Web Service control. But you should not use a Web Service control to invoke a web service that resides in the same application. Invoking a web service via a Web Service control means marshalling the method parameters into a SOAP message on the calling end and unmarshalling the SOAP message on the receiving end, then again for the method return value. This is very inefficient when the invocation is local. You would usually be tempted to invoke one web service from another if the called web service included business logic you want to access from the calling web service.

In general, you should place business logic in custom Java controls instead of in web services. This allows you to access the business logic from various contexts in the application (web services, other controls, page flows) without incurring the cost of data marshalling and unmarshalling. Web Service controls should only be used to invoke web services that are truly external to your application.

If you insist, you can create a Web Service control for a web service in a different project in the same way that you create Web Service control for any other web service. You must obtain either a WSDL or a JCX file for the web service you want to call.

To learn more about obtaining JCX files and WSDL files, see JCX Files: Implementing Controls and WSDL Files: Web Service Descriptions.

Once you have obtained a JCX or WSDL file, you must move it into the project from which you will be using it. For more information, see How Do I: Move or Copy a Web Service from One Project to Another?

If you have a WSDL file for the target web service in your project directory, a Web Service control may be generated by right-clicking on the JWS file and selecting Generate Service Control.

To learn more about creating and using Web Service controls, see Creating a New Web Service Control.

Related Topics

Web Service Control