Dynamic Proxy Client and Authentication

From: Dang Thi Phuong Nhi <>
Date: Wed, 10 Aug 2005 21:18:34 +0700

Please help me!
This is my

package dynamicproxy;

import javax.xml.rpc.Service;
import javax.xml.rpc.JAXRPCException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceFactory;
import dynamicproxy.*;

public class MathClient {

   public static void main(String[] args) {
      try {
         String nameSpaceUri = "urn:Foo";
         String serviceName = "MyFirstService";
         String portName = "MathFacePort";

         // Specify the location of the WSDL file
         URL url = new URL("http://localhost:8081/math-service/math?WSDL");

         // Create an instance of service factory
         ServiceFactory serviceFactory = ServiceFactory.newInstance();

         // Create a service object to act as a factory for proxies.
         Service mathService = serviceFactory.createService(url,
                    new QName(nameSpaceUri, serviceName));

         // Create a proxy
                    myProxy = (dynamicproxy.MathFace) mathService.getPort(new
                    portName), dynamicproxy.MathFace.class);

         // Invoke the add method
         System.out.println(myProxy.add(23, 12));
      } catch (Exception ex) {

I've authenticate in dynamic proxy but it has some mistake when I execute it:

E:\Projects\client\dynamic-proxy>java -classpath %classpath%;build dynamicproxy.
javax.xml.rpc.ServiceException: modeler error: failed to parse document at "http
://localhost:8081/math-service/math?WSDL": Server returned
HTTP response code: 401 for URL: http://localhost:8081/math-service/math?WSDL
        at com.sun.xml.rpc.client.dii.ConfiguredService.<init>(ConfiguredService
        at com.sun.xml.rpc.client.dii.ConfiguredService.<init>(ConfiguredService
        at com.sun.xml.rpc.client.ServiceFactoryImpl.createService(ServiceFactor
        at dynamicproxy.MathClient.main(


Please correct it for me.
Thank you very much indeed.

Dang Thi Phuong Nhi
Software Developer
Technology Consultancy, Investment and Development Company Limited
Suite 1001, 10th Floor, Building 17T3 Trung Hoa - Nhan Chinh Area,
Tran Duy Hung Road, Cau Giay, Ha Noi.
Tel: +84 - 4 - 2510938
Fax: +84 - 4 - 2510939