Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.此内容没有您所选择的语言版本。
Chapter 2. Developing a Consumer Without a WSDL Contract
Abstract
						You do not need a WSDL contract to develop a service consumer. You can create a service consumer from an annotated SEI. Along with the SEI you need to know the address at which the endpoint exposing the service is published, the QName of the service element that defines the endpoint exposing the service, and the QName of the port element defining the endpoint on which your consumer makes requests. This information can be specified in the SEI's annotations or provided separately.
					
				To create a consumer without a WSDL contract you must do the following:
			
- Create a
Serviceobject for the service on which the consumer will invoke operations. - Add a port to the
Serviceobject. 
2.1. Creating a Service Object 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
Overview 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
					The 
javax.xml.ws.Service class represents the wsdl:service element which contains the definition of all of the endpoints that expose a service. As such, it provides methods that allow you to get endpoints, defined by wsdl:port elements, that are proxies for making remote invocations on a service.
				Note
						The 
Service class provides the abstractions that allow the client code to work with Java types as opposed to working with XML documents.
					The create() methods 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
					The 
Service class has two static create() methods that can be used to create a new Service object. As shown in Example 2.1, “Service create() Methods”, both of the create() methods take the QName of the wsdl:service element the Service object will represent, and one takes a URI specifying the location of the WSDL contract.
				Tip
					All services publish their WSDL contracts. For SOAP/HTTP services the URI is usually the URI for the service appended with 
?wsdl.
				Example 2.1. Service create() Methods
public static Service create(URL wsdlLocation,
                             QName serviceName)
    throws WebServiceException;public static Service create(QName serviceName)
    throws WebServiceException;
					The value of the 
serviceName parameter is a QName. The value of its namespace part is the target namespace of the service. The service's target namespace is specified in the targetNamespace property of the @WebService annotation. The value of the QName's local part is the value of wsdl:service element's name attribute. You can determine this value in one of the following ways:
				- It is specified in the serviceName property of the
@WebServiceannotation. - You append
Serviceto the value of the name property of the@WebServiceannotation. - You append
Serviceto the name of the SEI. 
Example 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
					Example 2.2, “Creating a 
Service Object” shows code for creating a Service object for the SEI shown in Example 1.7, “Fully Annotated SEI”.
				Example 2.2. Creating a Service Object
					The code in Example 2.2, “Creating a 
Service Object” does the following:
				- 1
 - Builds the QName for the service using the targetNamespace property and the name property of the
@WebServiceannotation. - 2
 - Calls the single parameter
create()method to create a newServiceobject.NoteUsing the single parametercreate()frees you from having any dependencies on accessing a WSDL contract.