Skip Headers
Oracle® Fusion Middleware Programming Advanced Features of JAX-WS Web Services for Oracle WebLogic Server
11g Release 1 (10.3.4)

Part Number E13734-03
Go to Documentation Home
Go to Book List
Book List
Go to Table of Contents
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Go to next page
View PDF

13 Creating Dynamic Proxy Clients

A dynamic proxy client enables a Web service client to invoke a Web service based on a service endpoint interface (SEI) dynamically at run-time without using clientgen.

The steps to create a dynamic proxy client are outlined in the following table. For more information, see the Javadoc at

Table 13-1 Steps to Create a Dynamic Proxy Client

Step Description


Create the instance.

Create the Service instance using the Service.create method.

You must pass the service name and optionally the location of the WSDL document. The method details are as follows:

public static Service create (QName serviceName) throws {}
public static Service create (URL wsdlDocumentLocation, QName serviceName) throws {}

For example:

URL wsdlLocation = new URL("");
QName serviceName = new QName("", "MyService");
Service s = Service.create(wsdlLocation, serviceName);

See Additional Considerations When Specifying WSDL Location for additional usage information.


Create the proxy stub.

Use the Service.getPort method to create the proxy stub. You can use this stub to invoke operations on the target service endpoint.

You must pass the service endpoint interface (SEI) and optionally the name of the port in the WSDL service description. The method details are as follows:

public <T> T getPort(QName portName, Class<T> serviceEndpointInterface) throws {}
public <T> T getPort(Class<T> serviceEndpointInterface) throws {}

For example:

MyPort port = s.getPort(MyPort.class);

Additional Considerations When Specifying WSDL Location

If you use HTTPS to get the Web service from the WSDL, and the hostname definition in the WebLogic Server SSL certificate does not equal the hostname of the peer HTTPS server or is not one of the following, the action fails with a hostname verification error:

The hostname verification error is as follows:

EchoService service = new EchoService(https-wsdl, webservice-qName);
Security:090504 Certificate chain received from -
failed hostname verification check. Certificate contained {....} but
check expected

The recommended workaround is to use HTTP instead of HTTPS to get the Web service from a WSDL when creating the service, and your own hostname verifier code to verify the hostname after the service is created:

EchoService service = Service.create(http_wsdl, qname);
//get Port
EchoPort port = service.getPort(...);
//set self-defined hostname verifier
((BindingProvider) port).getRequestContext().put(,
      new  MyHostNameVerifier());

Optionally, you can ignore hostname verification by setting the binding provider property:

((BindingProvider) port).getRequestContext().put(

However, if you must use HTTPS to get the Web service from the WSDL, there are several possible workarounds:

For the workarounds in which you set your own hostname verifier, an example hostname verifier might be as follows:

public class MyHostnameVerifier implements HostnameVerifier {
    public boolean verify(String hostname, SSLSession session) {
            if (hostname.equals(“the host you want”))
          return true;
               return false;