title: Extending php SoapClient for siteminder authentication
body: <h2>Short Version</h2>
  
  <p>I want to extend <code>SoapClient</code> so it does this internally when accessing the WSDL:</p>
  
  <pre><code>curl -L -E /location/of/cert.pem -c /tmp/location/of/cookie.jar https://web-service-provider/servicename?wsdl
  </code></pre>
  
  <h2>Long Version</h2>
  
  <p>I've got a SOAP request similar to this:</p>
  
  <pre><code>$serviceUrl = 'https://service-url';
  $wsdl = $serviceUrl . '?wsdl';
  
  $proxyServiceUrl = 'http://localhost/myproxy.php?url=$serviceUrl';
  $proxyWsdl = 'http://localhost/myproxy.php?url=$wsdl';
  
  $options = array(
    'cache_wsdl'    =&gt; WSDL_CACHE_NONE,
    'encoding'      =&gt; 'utf-8',
    'soap_version'  =&gt; SOAP_1_1,
    'exceptions'    =&gt; true,
    'trace'         =&gt; true,
    'location'      =&gt; $proxyServiceUrl
  );
  
  $client = new SoapClient($proxyWsdl, $options);
  
  $params = array( /* */ );
  $client-&gt;someOperation($params);
  </code></pre>
  
  <p>As you can see, everything is pretty standard except for the proxy bit.</p>
  
  <p><strong>Reason for the proxy</strong></p>
  
  <p>I wrote the proxy to fulfill a requirement by the web service provider that all end-points including the WSDL be processed through an authentication system called siteminder.</p>
  
  <p>The function of the proxy is quite straight forward, if written in linux command line curl it would be something like this:</p>
  
  <pre><code>curl -L -E /location/of/cert.pem -c /tmp/location/of/cookie.jar https://web-service-provider/servicename?wsdl
  </code></pre>
  
  <p>To be precise:</p>
  
  <pre><code>* Follow all redirections
  * specify location of .pem file (and password)
  * specify location of cookie jar
  </code></pre>
  
  <p>This all works fine :)</p>
  
  <p><strong>BUT</strong> recently the service provider decided to changes it's WSDL.</p>
  
  <p>It now imports schema files (<code>.xsd</code>), which is not all that bad, except it is relative to the WSDL.</p>
  
  <p>Being relative to the WSDL file means that the <code>SoapClient</code> parser now looks for the schema files from the proxy's location. ERROR, can't find!</p>
  
  <p>More details about that problem here:</p>
  
  <p><a href="https://stackoverflow.com/questions/6132515/php-soapclient-fails-when-passed-a-wsdl-with-relative-path-schemas">php SoapClient fails when passed a wsdl with relative path schemas</a></p>
  
  <p><strong>So My Question Is:</strong></p>
  
  <p>How can I rewrite <code>SoapClient</code> (By Extending it of course), to still go through the siteminder authentication but without having to go through that extra proxy?</p>
  
  <p>My initial thoughts are that somehow I have to rewrite the URI accessor function (if one exists) but without much documenation in this area I'm not sure where to start.</p>
  
  <p>Alternatively, I might have to hack <code>SoapServer</code> somehow.</p>
  
  <p>I would appreciate any help I can get, including pointers to any documentation into the internals of <code>SoapClient</code>.</p>