[ 
https://issues.apache.org/jira/browse/AXIS2-3838?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jay Blanton updated AXIS2-3838:
-------------------------------

    Description: 
Assuming this is how the Options works, we create the Options object and set 
some of its attributes such as timeout, how to handle soap faults, as well as 
the EndpointReference.  Currently we cannot use the address that is located in 
the port section of the WSDL because our ESB overrides this location with a 
server specific name and we need our EndpointReference to be an internal domain 
that will route through our security firewalls, etc.  So because of this, we 
cannot just pull down the WSDL and post to that serviceName/portName's address 
location.  Because of this, we set the EndpointReference to the specific URL 
that we know should be used for submitting the service.

In order to help some performance, it was recommended in the Forums that one of 
the things that could be cached was the AxisService object.  So after we create 
the Options object, we check in a static map (with the WSDL URL as the key) to 
see if we already have an AxisService object created, if not, then we use the 
AxisService.createClientSideAxisService to create an AxisService by passing in 
the wsdlUrl/serviceName/portName/options.  After we get the AxisService object 
back, we store it in a static map for later retrieval from subsequent requests. 
 We then create a ServiceClient object with a null ConfigurationContext and the 
AxisService object we just cached.  After we do this we set the Options (even 
thought we used it in the constructor in the 
createClientSideAxisService...mainly because we create the ServiceClient a 
different way for testing).  Once this is complete, we return the ServiceClient 
and then we submit that request with the ServiceClient method that maps to th
 e MEP.

The problem that occurs is that the first service POST is posted to the WSDL 
Address Location and the second (and subsequent requests) are POST'd to the URL 
that we specify in the EndpointReference.  So what you will see in the code is 
the following:

First Request
1) Create an Options Object
2) Has the AxisService Object already been created for this WSDL 
3) The answer is no
4) Create the AxisService Object with the createClientSideAxisService method 
passing in the wsdlUrl, serviceName, portName, and the Options Object
5) Internally in the Axis2 API, a get request is sent to retrieve the wsdlUrl 
and the port address in the WSDL is set to override the value in the Options 
Object and so now the Options Object has been modified with the 
EndpointReference set to the one in the WSDL.
6) We create a ServiceClient object
7) We set the Options to the ServiceClient (and the Options object has been 
modified by the createClientSideAxisService method)
8) We return the ServiceClient, the POST is then made to the EndpointReference 
that has the WSDL port's address

Second Request
1) Create an Options Object
2) Has the AxisService Object already been created for this WSDL
3) The answer is yes
4) Retrieve the AxisService Object thats was cached with the incorrect 
EndpointReference (pointing to the WSDL's port address)
5) We create a ServiceClient object
6) We set the Options to the ServiceClient (and the Options object is newly 
created with the correct EndpointReference)
7) We return the ServiceClient, the POST is then made to the correct 
EndpointReference

So the question or bug is related to the fact that if you set the 
EndpointReference in the Options object, this should override any address found 
in the WSDL port location.  I would assume this because if I exclude the 
EndpointReference from the Options object, it correctly posts to the WSDL port 
location everytime.

    /**
     * Gets the service client.
     *
     * @return the service client
     */
    private ServiceClient getServiceClient() {
        ServiceClient mSender = null;

        try {
            WebMethod webMethod =
                
(WebMethod)AnnotationsHelper.getMethodAnnotation(getRequestWrapper().getMethodName(),
                    getRequestWrapper().getDaoClass(), WebMethod.class);
            WebService webService =
                
(WebService)getRequestWrapper().getDaoClass().getAnnotation(WebService.class);
            String endpointInterface =
                
WebServicePropertiesHelper.getProperty(webService.propertiesFile(),
                    webService.endpointInterface());
            String timeout =
                
WebServicePropertiesHelper.getProperty(webService.propertiesFile(),
                    webService.timeout());
            String envelopeNamespace =
                
WebServicePropertiesHelper.getProperty(webService.propertiesFile(),
                    webService.envelopeNamespace());
            String portName =
                
WebServicePropertiesHelper.getProperty(webService.propertiesFile(),
                    webService.portName());
            String serviceName =
                
WebServicePropertiesHelper.getProperty(webService.propertiesFile(),
                    webService.serviceName());

            //Setting the options for the service client
            Options options = new Options();
            options.setProperty(HTTPConstants.SO_TIMEOUT, new Integer(timeout));
            options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, new 
Integer(timeout));
            options.setSoapVersionURI(envelopeNamespace);
            options.setTo(new EndpointReference(endpointInterface));
            options.setExceptionToBeThrownOnSOAPFault(true);
            options.setCallTransportCleanup(true);
            
if(webService.endpointInterface().toUpperCase().startsWith("HTTP:")) {
                options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
            }
            else 
if(webService.endpointInterface().toUpperCase().startsWith("HTTPS:")) {
                options.setTransportInProtocol(Constants.TRANSPORT_HTTPS);
            }

            if(StringUtils.isNotEmpty(webMethod.action())) {
                options.setAction(webMethod.action());
            }

            //Narrowing the service details by retrieving and creating a 
wsdlServiceName
            //and including the portName in the ServiceClient instantiation if 
those
            //values exist.
            QName wsdlServiceName = null;

            if(StringUtils.isNotEmpty(webService.targetNamespace()) &&
                  StringUtils.isNotEmpty(serviceName)) {
                wsdlServiceName = new QName(webService.targetNamespace(), 
serviceName);
            }

            mSender = null;

            if(mockedService) {
                mSender = new ServiceClient();
            }
            else {
                String wsdlUrlString = wsdlUrl.toString();
                if(!axisServices.containsKey(wsdlUrlString)) {
                    axisServices.put(wsdlUrlString, 
AxisService.createClientSideAxisService(wsdlUrl, wsdlServiceName, portName, 
options));
                }
                mSender = new ServiceClient(null, 
axisServices.get(wsdlUrl.toString()));
            }
            mSender.setOptions(options);
        }
        catch(NumberFormatException e) {
            throw new WebServiceException(e);
        }
        catch(AxisFault e) {
            throw new WebServiceException(e);
        }

        return mSender;
    }

We have a current work around by doing the following when creating the 
AxisService Object:

                String wsdlUrlString = wsdlUrl.toString();
                AxisService svc = axisServices.get(wsdlUrlString);
                if(svc == null) {
                    svc = AxisService.createClientSideAxisService(wsdlUrl, 
wsdlServiceName, portName, options);
                    EndpointReference endPntRef = options.getTo();
                    if (endPntRef != null) {
                        endPntRef.setAddress(endpointInterface);
                    }
                    else {
                        options.setTo(new EndpointReference(endpointInterface));
                    }
                }
                mSender = new ServiceClient(null, 
axisServices.get(wsdlUrl.toString()));

Thanks -jay

  was:
Assuming this is how the Options works, we create the Options object and set 
some of its attributes such as timeout, how to handle soap faults, as well as 
the EndpointReference.  Currently we cannot use the address that is located in 
the port section of the WSDL because our ESB overrides this location with a 
server specific name and we need our EndpointReference to be an internal domain 
that will route through our security firewalls, etc.  So because of this, we 
cannot just pull down the WSDL and post to that serviceName/portName's address 
location.  Because of this, we set the EndpointReference to the specific URL 
that we know should be used for submitting the service.

In order to help some performance, it was recommended in the Forums that one of 
the things that could be cached was the AxisService object.  So after we create 
the Options object, we check in a static map (with the WSDL URL as the key) to 
see if we already have an AxisService object created, if not, then we use the 
AxisService.createClientSideAxisService to create an AxisService by passing in 
the wsdlUrl/serviceName/portName/options.  After we get the AxisService object 
back, we store it in a static map for later retrieval from subsequent requests. 
 We then create a ServiceClient object with a null ConfigurationContext and the 
AxisService object we just cached.  After we do this we set the Options (even 
thought we used it in the constructor in the 
createClientSideAxisService...mainly because we create the ServiceClient a 
different way for testing).  Once this is complete, we return the ServiceClient 
and then we submit that request with the ServiceClient method that maps to th
 e MEP.

The problem that occurs is that the first service POST is posted to the WSDL 
Address Location and the second (and subsequent requests) are POST'd to the URL 
that we specify in the EndpointReference.  So what you will see in the code is 
the following:

First Request
1) Create an Options Object
2) Has the AxisService Object already been created for this WSDL 
3) The answer is no
4) Create the AxisService Object with the createClientSideAxisService method 
passing in the wsdlUrl, serviceName, portName, and the Options Object
5) Internally in the Axis2 API, a get request is sent to retrieve the wsdlUrl 
and the port address in the WSDL is set to override the value in the Options 
Object and so now the Options Object has been modified with the 
EndpointReference set to the one in the WSDL.
6) We create a ServiceClient object
7) We set the Options to the ServiceClient (and the Options object has been 
modified by the createClientSideAxisService method)
8) We return the ServiceClient, the POST is then made to the EndpointReference 
that has the WSDL port's address

Second Request
1) Create an Options Object
2) Has the AxisService Object already been created for this WSDL
3) The answer is yes
4) Retrieve the AxisService Object thats was cached with the incorrect 
EndpointReference (pointing to the WSDL's port address)
5) We create a ServiceClient object
6) We set the Options to the ServiceClient (and the Options object is newly 
created with the correct EndpointReference)
7) We return the ServiceClient, the POST is then made to the correct 
EndpointReference

So the question or bug is related to the fact that if you set the 
EndpointReference in the Options object, this should override any address found 
in the WSDL port location.  I would assume this because if I exclude the 
EndpointReference from the Options object, it correctly posts to the WSDL port 
location everytime.

    /**
     * Gets the service client.
     *
     * @return the service client
     */
    private ServiceClient getServiceClient() {
        ServiceClient mSender = null;

        try {
            WebMethod webMethod =
                
(WebMethod)AnnotationsHelper.getMethodAnnotation(getRequestWrapper().getMethodName(),
                    getRequestWrapper().getDaoClass(), WebMethod.class);
            WebService webService =
                
(WebService)getRequestWrapper().getDaoClass().getAnnotation(WebService.class);
            String endpointInterface =
                
WebServicePropertiesHelper.getProperty(webService.propertiesFile(),
                    webService.endpointInterface());
            String timeout =
                
WebServicePropertiesHelper.getProperty(webService.propertiesFile(),
                    webService.timeout());
            String envelopeNamespace =
                
WebServicePropertiesHelper.getProperty(webService.propertiesFile(),
                    webService.envelopeNamespace());
            String portName =
                
WebServicePropertiesHelper.getProperty(webService.propertiesFile(),
                    webService.portName());
            String serviceName =
                
WebServicePropertiesHelper.getProperty(webService.propertiesFile(),
                    webService.serviceName());

            //Setting the options for the service client
            Options options = new Options();
            options.setProperty(HTTPConstants.SO_TIMEOUT, new Integer(timeout));
            options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, new 
Integer(timeout));
            options.setSoapVersionURI(envelopeNamespace);
            options.setTo(new EndpointReference(endpointInterface));
            options.setExceptionToBeThrownOnSOAPFault(true);
            options.setCallTransportCleanup(true);
            
if(webService.endpointInterface().toUpperCase().startsWith("HTTP:")) {
                options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
            }
            else 
if(webService.endpointInterface().toUpperCase().startsWith("HTTPS:")) {
                options.setTransportInProtocol(Constants.TRANSPORT_HTTPS);
            }

            if(StringUtils.isNotEmpty(webMethod.action())) {
                options.setAction(webMethod.action());
            }

            //Narrowing the service details by retrieving and creating a 
wsdlServiceName
            //and including the portName in the ServiceClient instantiation if 
those
            //values exist.
            QName wsdlServiceName = null;

            if(StringUtils.isNotEmpty(webService.targetNamespace()) &&
                  StringUtils.isNotEmpty(serviceName)) {
                wsdlServiceName = new QName(webService.targetNamespace(), 
serviceName);
            }

            mSender = null;

            if(mockedService) {
                mSender = new ServiceClient();
            }
            else {
                String wsdlUrlString = wsdlUrl.toString();
                if(!axisServices.containsKey(wsdlUrlString)) {
                    axisServices.put(wsdlUrlString, 
AxisService.createClientSideAxisService(wsdlUrl, wsdlServiceName, portName, 
options));
                }
                mSender = new ServiceClient(null, 
axisServices.get(wsdlUrl.toString()));
            }
            mSender.setOptions(options);
        }
        catch(NumberFormatException e) {
            throw new WebServiceException(e);
        }
        catch(AxisFault e) {
            throw new WebServiceException(e);
        }

        return mSender;
    }

We have a current work around by doing the following when creating the 
AxisService Object:

                String wsdlUrlString = wsdlUrl.toString();
                AxisService svc = axisServices.get(wsdlUrlString);
                if(svc == null) {
                    svc = AxisService.createClientSideAxisService(wsdlUrl, 
wsdlServiceName, portName, options);
                    EndpointReference endPntRef = options.getTo();
                    if (endPntRef != null) {
                        endPntRef.setAddress(endpointInterface);
                    }
                    else {
                        options.setTo(new EndpointReference(endpointInterface));
                    }
                mSender = new ServiceClient(null, 
axisServices.get(wsdlUrl.toString()));

Thanks -jay


> options.setTo(new EndpointReference(endpointInterface)) is overridden by 
> AxisService.createClientSideAxisService and the address location in the WSDL 
> port
> ----------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: AXIS2-3838
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3838
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>          Components: client-api
>    Affects Versions: 1.3
>         Environment: Windows XP, Eclipse 3.3, WebLogic 9.2 (Web Application), 
> JDK 1.5, AquaLogic Service Bus (ESB), WebLogic 10 (Service Container)
>            Reporter: Jay Blanton
>
> Assuming this is how the Options works, we create the Options object and set 
> some of its attributes such as timeout, how to handle soap faults, as well as 
> the EndpointReference.  Currently we cannot use the address that is located 
> in the port section of the WSDL because our ESB overrides this location with 
> a server specific name and we need our EndpointReference to be an internal 
> domain that will route through our security firewalls, etc.  So because of 
> this, we cannot just pull down the WSDL and post to that 
> serviceName/portName's address location.  Because of this, we set the 
> EndpointReference to the specific URL that we know should be used for 
> submitting the service.
> In order to help some performance, it was recommended in the Forums that one 
> of the things that could be cached was the AxisService object.  So after we 
> create the Options object, we check in a static map (with the WSDL URL as the 
> key) to see if we already have an AxisService object created, if not, then we 
> use the AxisService.createClientSideAxisService to create an AxisService by 
> passing in the wsdlUrl/serviceName/portName/options.  After we get the 
> AxisService object back, we store it in a static map for later retrieval from 
> subsequent requests.  We then create a ServiceClient object with a null 
> ConfigurationContext and the AxisService object we just cached.  After we do 
> this we set the Options (even thought we used it in the constructor in the 
> createClientSideAxisService...mainly because we create the ServiceClient a 
> different way for testing).  Once this is complete, we return the 
> ServiceClient and then we submit that request with the ServiceClient method 
> that maps to 
 the MEP.
> The problem that occurs is that the first service POST is posted to the WSDL 
> Address Location and the second (and subsequent requests) are POST'd to the 
> URL that we specify in the EndpointReference.  So what you will see in the 
> code is the following:
> First Request
> 1) Create an Options Object
> 2) Has the AxisService Object already been created for this WSDL 
> 3) The answer is no
> 4) Create the AxisService Object with the createClientSideAxisService method 
> passing in the wsdlUrl, serviceName, portName, and the Options Object
> 5) Internally in the Axis2 API, a get request is sent to retrieve the wsdlUrl 
> and the port address in the WSDL is set to override the value in the Options 
> Object and so now the Options Object has been modified with the 
> EndpointReference set to the one in the WSDL.
> 6) We create a ServiceClient object
> 7) We set the Options to the ServiceClient (and the Options object has been 
> modified by the createClientSideAxisService method)
> 8) We return the ServiceClient, the POST is then made to the 
> EndpointReference that has the WSDL port's address
> Second Request
> 1) Create an Options Object
> 2) Has the AxisService Object already been created for this WSDL
> 3) The answer is yes
> 4) Retrieve the AxisService Object thats was cached with the incorrect 
> EndpointReference (pointing to the WSDL's port address)
> 5) We create a ServiceClient object
> 6) We set the Options to the ServiceClient (and the Options object is newly 
> created with the correct EndpointReference)
> 7) We return the ServiceClient, the POST is then made to the correct 
> EndpointReference
> So the question or bug is related to the fact that if you set the 
> EndpointReference in the Options object, this should override any address 
> found in the WSDL port location.  I would assume this because if I exclude 
> the EndpointReference from the Options object, it correctly posts to the WSDL 
> port location everytime.
>     /**
>      * Gets the service client.
>      *
>      * @return the service client
>      */
>     private ServiceClient getServiceClient() {
>         ServiceClient mSender = null;
>         try {
>             WebMethod webMethod =
>                 
> (WebMethod)AnnotationsHelper.getMethodAnnotation(getRequestWrapper().getMethodName(),
>                     getRequestWrapper().getDaoClass(), WebMethod.class);
>             WebService webService =
>                 
> (WebService)getRequestWrapper().getDaoClass().getAnnotation(WebService.class);
>             String endpointInterface =
>                 
> WebServicePropertiesHelper.getProperty(webService.propertiesFile(),
>                     webService.endpointInterface());
>             String timeout =
>                 
> WebServicePropertiesHelper.getProperty(webService.propertiesFile(),
>                     webService.timeout());
>             String envelopeNamespace =
>                 
> WebServicePropertiesHelper.getProperty(webService.propertiesFile(),
>                     webService.envelopeNamespace());
>             String portName =
>                 
> WebServicePropertiesHelper.getProperty(webService.propertiesFile(),
>                     webService.portName());
>             String serviceName =
>                 
> WebServicePropertiesHelper.getProperty(webService.propertiesFile(),
>                     webService.serviceName());
>             //Setting the options for the service client
>             Options options = new Options();
>             options.setProperty(HTTPConstants.SO_TIMEOUT, new 
> Integer(timeout));
>             options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, new 
> Integer(timeout));
>             options.setSoapVersionURI(envelopeNamespace);
>             options.setTo(new EndpointReference(endpointInterface));
>             options.setExceptionToBeThrownOnSOAPFault(true);
>             options.setCallTransportCleanup(true);
>             
> if(webService.endpointInterface().toUpperCase().startsWith("HTTP:")) {
>                 options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
>             }
>             else 
> if(webService.endpointInterface().toUpperCase().startsWith("HTTPS:")) {
>                 options.setTransportInProtocol(Constants.TRANSPORT_HTTPS);
>             }
>             if(StringUtils.isNotEmpty(webMethod.action())) {
>                 options.setAction(webMethod.action());
>             }
>             //Narrowing the service details by retrieving and creating a 
> wsdlServiceName
>             //and including the portName in the ServiceClient instantiation 
> if those
>             //values exist.
>             QName wsdlServiceName = null;
>             if(StringUtils.isNotEmpty(webService.targetNamespace()) &&
>                   StringUtils.isNotEmpty(serviceName)) {
>                 wsdlServiceName = new QName(webService.targetNamespace(), 
> serviceName);
>             }
>             mSender = null;
>             if(mockedService) {
>                 mSender = new ServiceClient();
>             }
>             else {
>                 String wsdlUrlString = wsdlUrl.toString();
>                 if(!axisServices.containsKey(wsdlUrlString)) {
>                     axisServices.put(wsdlUrlString, 
> AxisService.createClientSideAxisService(wsdlUrl, wsdlServiceName, portName, 
> options));
>                 }
>                 mSender = new ServiceClient(null, 
> axisServices.get(wsdlUrl.toString()));
>             }
>             mSender.setOptions(options);
>         }
>         catch(NumberFormatException e) {
>             throw new WebServiceException(e);
>         }
>         catch(AxisFault e) {
>             throw new WebServiceException(e);
>         }
>         return mSender;
>     }
> We have a current work around by doing the following when creating the 
> AxisService Object:
>                 String wsdlUrlString = wsdlUrl.toString();
>                 AxisService svc = axisServices.get(wsdlUrlString);
>                 if(svc == null) {
>                     svc = AxisService.createClientSideAxisService(wsdlUrl, 
> wsdlServiceName, portName, options);
>                     EndpointReference endPntRef = options.getTo();
>                     if (endPntRef != null) {
>                         endPntRef.setAddress(endpointInterface);
>                     }
>                     else {
>                         options.setTo(new 
> EndpointReference(endpointInterface));
>                     }
>                 }
>                 mSender = new ServiceClient(null, 
> axisServices.get(wsdlUrl.toString()));
> Thanks -jay

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to