import com.aol.fog.fr.objects.*;

import java.net.URL;
import javax.xml.rpc.Service;
import javax.xml.rpc.JAXRPCException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceFactory;

public class FogWSDynClient {

    public static void main(String[] args) {

    try {
        String endpointAddress = "http://ymir.office.compuserve.com:9221/axis/services/urn:FadFogwService";
        String UrlString = "http://ymir.office.compuserve.com:9221/axis/services/urn:FadFogwService?WSDL";
        String nameSpaceUri = "http://ymir.office.compuserve.com:9221/axis/services/urn:FadFogwService";
        String serviceName = "FadFogwServiceService";
        String portName = "urn:FadFogwService";

        URL fogWSDLUrl = new URL(UrlString);
        ServiceFactory serviceFactory = ServiceFactory.newInstance();

        Service fogwService = serviceFactory.createService
                              (fogWSDLUrl, new QName(nameSpaceUri, serviceName));

        FadFogwService myProxy = (FadFogwService) fogwService.getPort
                                 (new QName(nameSpaceUri, portName),
                                  FadFogwService.class);
                                  
      try {
           System.out.println ("FOG WebService client calling order method");
           OrderRequest request = new OrderRequest();

           //set ADSL Address details
           Address adslAddress = new Address();
           adslAddress.setTitle("test");
           adslAddress.setFirst_name("roger");
           adslAddress.setLast_name("lucien");
           adslAddress.setStreet1("5 rue du condor");
           adslAddress.setCity("paris");
           adslAddress.setPostal("75003");
           
           request.setAdsl_address(adslAddress);
           
           OrderResponse response = myProxy.order(request);
        } catch (Exception exc) {
           System.out.println ("Error while calling order method on FOG Web Service");
           System.out.println(exc.getMessage());
           exc.printStackTrace();
        }
                
        } catch (Exception exc) {
           System.out.println ("Error while creating proxy of FOG Web Service");
           System.out.println(exc.getMessage());
           exc.printStackTrace();
        }