title: JaxWS : Externalize Http Conduit name Attribute
body: <p>I have the WSDL file for the SOAP webservice that i need to invoke over http. Using cxf wsdl2java plugin i have created the stub methods.</p>
  
  <p><strong>I have created the webservice client using jaxws. The webservice has basic authentication enabled. I am trying to configure http conduit</strong></p>
  
  <pre><code> my application.properties
   --------------------------
   webservices.http.auth.username=username
   webservices.http.auth.password=password
   fold.webservices.http.auth.authtype=Basic
   webservices.http.conduit.property.name=https://fixed_deposits-test.co.in/fold-webservices/services.*
   fold.updateservice.soap.address=https://fixed_deposits-test.co.in/fold-webservices/services/UpdateService
   ----------------------------     
  </code></pre>
  
  <blockquote>
    <p><strong>My Spring Context...</strong></p>
  </blockquote>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
   &lt;beans xmlns="http://www.springframework.org/schema/beans"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:jaxws="http://cxf.apache.org/jaxws"
          xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
          xmlns:sec="http://cxf.apache.org/configuration/security"
          xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                      http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
                      http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
                      http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"&gt;
  
     &lt;bean id="properties" class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer"&gt;
        &lt;property name="locations"&gt;
          &lt;util:list&gt;
              &lt;value&gt;file:${config.dir}/application.properties&lt;/value&gt;
          &lt;/util:list&gt;
        &lt;/property&gt;
      &lt;property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" /&gt;
     &lt;/bean&gt;
  
     &lt;jaxws:client id="updateServiceClient" serviceClass="com.fold.facade.v1.UpdateService" address="${fold.updateservice.soap.address}" &gt;
        &lt;jaxws:inInterceptors&gt;
          &lt;bean id="loggingInInterceptor" class="org.apache.cxf.interceptor.LoggingInInterceptor" &gt;
              &lt;property name="prettyLogging" value="true" /&gt;
          &lt;/bean&gt;
        &lt;/jaxws:inInterceptors&gt;
        &lt;jaxws:outInterceptors&gt;
          &lt;bean id="loggingOutInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor" &gt;
              &lt;property name="prettyLogging" value="true" /&gt;
          &lt;/bean&gt;
        &lt;/jaxws:outInterceptors&gt;
     &lt;/jaxws:client&gt;
  
    &lt;http-conf:conduit name="***?????????***"&gt;
      &lt;http-conf:authorization&gt;
          &lt;sec:UserName&gt;${fold.webservices.http.auth.username}&lt;/sec:UserName&gt;
          &lt;sec:Password&gt;${fold.webservices.http.auth.password}&lt;/sec:Password&gt;
          &lt;sec:AuthorizationType&gt;${fold.webservices.http.auth.authtype}&lt;/sec:AuthorizationType&gt;
      &lt;/http-conf:authorization&gt;
  &lt;/http-conf:conduit&gt;
  </code></pre>
  
  <p>I have done a lot of searching online so as to what should be the valid value for <strong>name attribute..</strong></p>
  
  <p>accouring to CXF documentation it should be...</p>
  
  <pre><code>{WSDL_endpoint_target_namespace}PortName.http-conduit
  </code></pre>
  
  <p><strong>my WSDL File has..</strong></p>
  
  <pre><code>...
  targetNamespace="http://facade.fold.com/" and
  ...
  &lt;wsdl:port binding="tns:UpdateServiceImplServiceSoapBinding"
          name="UpdateServiceImplPort"&gt;
          &lt;soap:address
              location="https://fixed_deposits-test.co.in/fold-webservices/services/UpdateService" /&gt;
      &lt;/wsdl:port&gt;
  </code></pre>
  
  <p><strong>so i tried with these..</strong></p>
  
  <pre><code>&lt;http-conf:conduit name="{http://facade.fold.com/}UpdateServiceImplPort.http_conduit"&gt;
  or
  &lt;http-conf:conduit name="*UpdateServiceImplPort.http_conduit"&gt;
  or
  &lt;http-conf:conduit name="{http://facade.fold.com/}*.http_conduit"&gt;
  </code></pre>
  
  <p>But none of them work as i get 401 unauthorized exception..</p>
  
  <p><em>org.apache.cxf.transport.http.HTTPException: HTTP response '401: Unauthorized' when communicating with <a href="https://fixed_deposits-test.co.in/fold-webservices/services/UpdateService" rel="nofollow">https://fixed_deposits-test.co.in/fold-webservices/services/UpdateService</a></em></p>
  
  <blockquote>
    <p><strong><em>THERE ARE COUPLE OF WAYS I GOT IT TO WORK</em></strong></p>
  </blockquote>
  
  <pre><code>a) &lt;http-conf:conduit name="*.http_conduit"&gt;
  </code></pre>
  
  <p>but i really don't want to do it this way...</p>
  
  <pre><code>b) &lt;http-conf:conduit name="https://fixed_deposits-test.co.in/fold-webservices/services/UpdateService"&gt;
  </code></pre>
  
  <p>this is hardcoding the SOAP service URL... which i don't want as i am looking for externalizing URL as my SOAP URL's are different for different environment..(dev /test /prod etc)</p>
  
  <p><strong>Below is my best shot at externalization, but it failed with 401 Unauthorized Exception...</strong></p>
  
  <p>properties were replaced in all other instances in my spring context, but not for http-conf:conduit <strong>name attribute</strong> :(</p>
  
  <pre><code>&lt;http-conf:conduit name="${webservices.http.conduit.property.name}"&gt;
  </code></pre>
  
  <p>As a workaround i am currently using the regex approach which works..</p>
  
  <pre><code>&lt;http-conf:conduit name="*.*/fold-webservices/services/UpdateService"&gt;
  </code></pre>
  
  <blockquote>
    <p><strong><em>But i really want to figure out if it possible to externalize it and read from properties file. And i want to do it the Spring
    configuration way. Please help me !!!</em></strong></p>
  </blockquote>