<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>I'm Persian - SOAP</title>
    <link>http://gluegadget.com/blog/</link>
    <description>My land is Iran</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.4.1 - http://www.s9y.org/</generator>
    <pubDate>Thu, 22 May 2008 15:11:09 GMT</pubDate>

    <image>
        <url>http://gluegadget.com/blog/templates/bulletproof/img/s9y_banner_small.png</url>
        <title>RSS: I'm Persian - SOAP - My land is Iran</title>
        <link>http://gluegadget.com/blog/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Calling protected SOAP from Mozilla</title>
    <link>http://gluegadget.com/blog/index.php?/archives/25-Calling-protected-SOAP-from-Mozilla.html</link>
            <category>Mozilla</category>
            <category>SOAP</category>
            <category>Web Services</category>
    
    <comments>http://gluegadget.com/blog/index.php?/archives/25-Calling-protected-SOAP-from-Mozilla.html#comments</comments>
    <wfw:comment>http://gluegadget.com/blog/wfwcomment.php?cid=25</wfw:comment>

    <slash:comments>12</slash:comments>
    <wfw:commentRss>http://gluegadget.com/blog/rss.php?version=2.0&amp;type=comments&amp;cid=25</wfw:commentRss>
    

    <author>nospam@example.com (Amir Mohammad Saied)</author>
    <content:encoded>
    &lt;div align=&quot;left&quot; dir=&quot;ltr&quot;&gt;&lt;br /&gt;
Recently I had to write a Firefox extension for a &lt;a href=&quot;http://www.hostiran.net/&quot;&gt;company&lt;/a&gt; which provides &lt;a href=&quot;http://sms.hostiran.net/webservice/&quot;&gt;text messaging web services&lt;/a&gt;. The Web-Service is an RPC-Style SOAP one which is written by &lt;a href=&quot;http://blog.phpmystery.com/&quot;&gt;&quot;Nima Shayafar&quot;&lt;/a&gt;.&lt;br /&gt;
When I got this offer, I didn&#039;t think that this one would cause any troubles, as Mozilla has a SOAP implementation landed in it&#039;s platform since years (&lt;strike&gt;And if you ask me, I&#039;ll tell you no one, never touched it again to improve it -even a little bit&lt;/strike&gt; &lt;strong&gt;UPDATE:&lt;/strong&gt;&lt;em&gt;They finally touched it, and they completely removed it from Mozilla 1.9!&lt;/em&gt;&lt;img src=&quot;http://gluegadget.com/blog/templates/default/img/emoticons/tongue.png&quot; alt=&quot;:-P&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;).&lt;br /&gt;
This Web-Service is protected by basic HTTP Authentication, nothing tricky so far, but to my surprise Mozilla&#039;s SOAP implementation doesn&#039;t provide any mean to do authentication against an endpoint, and nah, not even a basic one.&lt;br /&gt;
Well I thought as this (writing Firefox extensions for protected SOAP Web Services) is not that uncommon situation I may get a good amount of information by Googling, but nothing catchy comes there in results except a thread at &lt;a href=&quot;http://groups.google.com/group/netscape.public.mozilla.xml/browse_thread/thread/b46993fbc34afee9/0aee2d3d620ff42e&quot;&gt;netscape.public.mozilla.xml&lt;/a&gt; where I found two solutions, one was submitting username/password pair together with URL, and the other one was to make an XHR connection to the endpoint (XMLHttpRequest implementation let you provide login/password for a basic authentication), and as Mozilla remembers that for the browser session, you&#039;re there.&lt;br /&gt;
The first solution is hmm ... horrible! And the second one, I didn&#039;t manage to get it to work.&lt;br /&gt;
So I started wondering in other possible ways to overcome this, and guess what? It was damn easy!&lt;br /&gt;
You just need to set Authorization header in HTTP request (which is base64 encoded of login:password), but just for that particular endpoint, and how?&lt;br /&gt;
You need to use nsIHttpChannel in conjugation with nsIObserverService, register it right before invoking the SOAPCall, and (don&#039;t forget to!) unregister it when the call is done, that&#039;s it.&lt;br /&gt;
Well, it took me an hour to come up with this, and I&#039;m writing it in hopes save someone else &quot;one hour&quot;.&lt;br /&gt;
&lt;/div&gt; 
    </content:encoded>

    <pubDate>Fri, 14 Dec 2007 02:16:00 -0500</pubDate>
    <guid isPermaLink="false">http://gluegadget.com/blog/index.php?/archives/25-guid.html</guid>
    
</item>

</channel>
</rss>