<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>php &#8211; Sanity Free Coding</title>
	<atom:link href="http://sanity-free.org/tag/php/feed" rel="self" type="application/rss+xml" />
	<link>http://sanity-free.org</link>
	<description>Methods to the Madness</description>
	<lastBuildDate>Thu, 20 Nov 2025 04:38:33 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>http://sanity-free.org/wp-content/uploads/2025/10/sanity-free-512-150x150.jpg</url>
	<title>php &#8211; Sanity Free Coding</title>
	<link>http://sanity-free.org</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Phalanger, PHP for .NET</title>
		<link>http://sanity-free.org/phalanger_php_for_dotnet.html</link>
		
		<dc:creator><![CDATA[steve]]></dc:creator>
		<pubDate>Thu, 25 Jan 2007 18:00:15 +0000</pubDate>
				<category><![CDATA[PHP Articles]]></category>
		<category><![CDATA[dotnet]]></category>
		<category><![CDATA[php]]></category>
		<guid isPermaLink="false">http://dev.sanity-free.org/?p=224</guid>

					<description><![CDATA[I ran across an article on the code project about a PHP compiler / language extension for .NET. PHP has an extension for .NET that allows you to use .NET resources in PHP code, but this allows you to use PHP from .NET, with support for native PHP API&#8217;s as well as managed compilation. This [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>I ran across an article on the code project about a PHP compiler / language extension for .NET.<br><br>PHP has an extension for .NET that allows you to use .NET resources in PHP code, but this allows you to use PHP from .NET, with support for native PHP API&#8217;s as well as managed compilation. This project may end up making my article on <a href="/php_webservices_and_csharp_dotnet_soap_clients.html" target="_blank" rel="noreferrer noopener">nusoap &amp; C#</a> obsolete, though it should make writing web services in PHP as easy as it is in C#.<br><br>»&nbsp;<a href="https://github.com/peachpiecompiler/peachpie" target="_blank" rel="noreferrer noopener">Phalanger Home</a> (now peachpie, link updated to new project)<br>»&nbsp;<s>Code Project Article</s> (long since abandoned)<br></p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="350" height="450" src="http://sanity-free.org/wp-content/uploads/2025/10/vsnetscreen.gif" alt="" class="wp-image-90"/></figure>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Triple DES between PHP and C#</title>
		<link>http://sanity-free.org/triple_des_between_php_and_csharp.html</link>
		
		<dc:creator><![CDATA[steve]]></dc:creator>
		<pubDate>Wed, 27 Sep 2006 18:00:01 +0000</pubDate>
				<category><![CDATA[C# Articles]]></category>
		<category><![CDATA[PHP Articles]]></category>
		<category><![CDATA[crossplatform]]></category>
		<category><![CDATA[crypto]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[dotnet]]></category>
		<category><![CDATA[php]]></category>
		<guid isPermaLink="false">http://dev.sanity-free.org/?p=205</guid>

					<description><![CDATA[The past while at work I&#8217;ve been working through some annoyingly over complicated encryption issues. The problem is not that Triple DES is all that complicated or annoying, it&#8217;s just that when you have 2 different technologies (one doing the encrypting and one doing the decrypting) at work; it can be frustrating to get anything [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>The past while at work I&#8217;ve been working through some annoyingly over complicated encryption issues. The problem is not that Triple DES is all that complicated or annoying, it&#8217;s just that when you have 2 different technologies (one doing the encrypting and one doing the decrypting) at work; it can be frustrating to get anything accomplished.<br><br>Our issues stemmed around the fact that we were using .NET 1.1 and they were using Java (with the standard crypto providers). There are a few subtleties between Microsoft&#8217;s crypto providers and Java&#8217;s. .NET provides 3 (OK, really only 2) Padding modes, and Java provides like 5, but they don&#8217;t provide any in common. One easy padding mode is to append 0x00 bytes to the end of the final block to make it an even 64 bits wide. The Java provider didn&#8217;t have this, but its easy enough to add ( by appending null char&#8217;s &#8216;\0&#8217; to the end of the string then calling <code>getBytes()</code> ). So that&#8217;s the route we took. After overcoming a few problems with &#8220;How do we encode our bytes used for the key and IV and still be compatible&#8221; we were off and running.<br><br>That made me wonder how compatible PHP and .NET&#8217;s 3DES were. Since I didn&#8217;t see any &#8220;Padding Mode&#8221; for PHP&#8217;s, I simply hand coded the padding the same way we did with the Java code.<br><br>Here&#8217;s my PHP script:</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers cbp-highlight-hover" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono-NL.ttf" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#24292eff;--cbp-line-number-width:calc(2 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(16, 41, 67, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#ffffff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#24292eff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>&lt;?php

if(!isset($_POST&#91;'op'&#93;)) {
    ?>
&lt;form id="form1" name="form1" method="post" action="">
  enter text
  &lt;input name="data" type="text" />
  &lt;input type="hidden" value="op" name="op" />
  &lt;input type="submit" name="Submit" value="Submit" />
&lt;/form>
    &lt;?php
}else {
    $buffer = $_POST&#91;'data'&#93;; 
    // get the amount of bytes to pad
    $extra = 8 - (strlen($buffer) % 8);
    // add the zero padding
    if($extra > 0) {
        for($i = 0; $i &lt; $extra; $i++) {
            $buffer .= "\0";
        }
    }
    // very simple ASCII key and IV
    $key = "passwordDR0wSS@P6660juht";
    $iv = "password";
    // hex encode the return value
    echo "Result: ".bin2hex(mcrypt_cbc(MCRYPT_3DES, $key, $buffer, MCRYPT_ENCRYPT, $iv));	
}
?></textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki min-light" style="background-color: #ffffff" tabindex="0"><code><span class="line"><span style="color: #D32F2F">&lt;?</span><span style="color: #24292EFF">php</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D32F2F">if</span><span style="color: #24292EFF">(</span><span style="color: #D32F2F">!</span><span style="color: #6F42C1">isset</span><span style="color: #212121">(</span><span style="color: #6F42C1">$_POST&#91;</span><span style="color: #22863A">&#39;op&#39;</span><span style="color: #6F42C1">&#93;</span><span style="color: #212121">)</span><span style="color: #24292EFF">) {</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #D32F2F">?&gt;</span></span>
<span class="line"><span style="color: #D32F2F">&lt;</span><span style="color: #24292EFF">form id</span><span style="color: #D32F2F">=</span><span style="color: #22863A">&quot;form1&quot;</span><span style="color: #24292EFF"> name</span><span style="color: #D32F2F">=</span><span style="color: #22863A">&quot;form1&quot;</span><span style="color: #24292EFF"> method</span><span style="color: #D32F2F">=</span><span style="color: #22863A">&quot;post&quot;</span><span style="color: #24292EFF"> action</span><span style="color: #D32F2F">=</span><span style="color: #22863A">&quot;&quot;</span><span style="color: #D32F2F">&gt;</span></span>
<span class="line"><span style="color: #24292EFF">  enter text</span></span>
<span class="line"><span style="color: #24292EFF">  </span><span style="color: #D32F2F">&lt;</span><span style="color: #24292EFF">input name</span><span style="color: #D32F2F">=</span><span style="color: #22863A">&quot;data&quot;</span><span style="color: #24292EFF"> type</span><span style="color: #D32F2F">=</span><span style="color: #22863A">&quot;text&quot;</span><span style="color: #24292EFF"> </span><span style="color: #D32F2F">/&gt;</span></span>
<span class="line"><span style="color: #24292EFF">  </span><span style="color: #D32F2F">&lt;</span><span style="color: #24292EFF">input type</span><span style="color: #D32F2F">=</span><span style="color: #22863A">&quot;hidden&quot;</span><span style="color: #24292EFF"> value</span><span style="color: #D32F2F">=</span><span style="color: #22863A">&quot;op&quot;</span><span style="color: #24292EFF"> name</span><span style="color: #D32F2F">=</span><span style="color: #22863A">&quot;op&quot;</span><span style="color: #24292EFF"> </span><span style="color: #D32F2F">/&gt;</span></span>
<span class="line"><span style="color: #24292EFF">  </span><span style="color: #D32F2F">&lt;</span><span style="color: #24292EFF">input type</span><span style="color: #D32F2F">=</span><span style="color: #22863A">&quot;submit&quot;</span><span style="color: #24292EFF"> name</span><span style="color: #D32F2F">=</span><span style="color: #22863A">&quot;Submit&quot;</span><span style="color: #24292EFF"> value</span><span style="color: #D32F2F">=</span><span style="color: #22863A">&quot;Submit&quot;</span><span style="color: #24292EFF"> </span><span style="color: #D32F2F">/&gt;</span></span>
<span class="line"><span style="color: #D32F2F">&lt;/</span><span style="color: #24292EFF">form</span><span style="color: #D32F2F">&gt;</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #D32F2F">&lt;?</span><span style="color: #24292EFF">php</span></span>
<span class="line"><span style="color: #24292EFF">}</span><span style="color: #D32F2F">else</span><span style="color: #24292EFF"> {</span></span>
<span class="line"><span style="color: #24292EFF">    $buffer </span><span style="color: #D32F2F">=</span><span style="color: #24292EFF"> $_POST&#91;</span><span style="color: #22863A">&#39;data&#39;</span><span style="color: #24292EFF">&#93;; </span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #C2C3C5">// get the amount of bytes to pad</span></span>
<span class="line"><span style="color: #24292EFF">    $extra </span><span style="color: #D32F2F">=</span><span style="color: #24292EFF"> </span><span style="color: #1976D2">8</span><span style="color: #24292EFF"> </span><span style="color: #D32F2F">-</span><span style="color: #24292EFF"> (</span><span style="color: #6F42C1">strlen</span><span style="color: #212121">(</span><span style="color: #6F42C1">$buffer</span><span style="color: #212121">)</span><span style="color: #24292EFF"> </span><span style="color: #D32F2F">%</span><span style="color: #24292EFF"> </span><span style="color: #1976D2">8</span><span style="color: #24292EFF">);</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #C2C3C5">// add the zero padding</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #D32F2F">if</span><span style="color: #24292EFF">($extra </span><span style="color: #D32F2F">&gt;</span><span style="color: #24292EFF"> </span><span style="color: #1976D2">0</span><span style="color: #24292EFF">) {</span></span>
<span class="line"><span style="color: #24292EFF">        </span><span style="color: #D32F2F">for</span><span style="color: #24292EFF">($i </span><span style="color: #D32F2F">=</span><span style="color: #24292EFF"> </span><span style="color: #1976D2">0</span><span style="color: #24292EFF">; $i </span><span style="color: #D32F2F">&lt;</span><span style="color: #24292EFF"> $extra; $i</span><span style="color: #D32F2F">++</span><span style="color: #24292EFF">) {</span></span>
<span class="line"><span style="color: #24292EFF">            $buffer </span><span style="color: #D32F2F">.=</span><span style="color: #24292EFF"> </span><span style="color: #22863A">&quot;\0&quot;</span><span style="color: #24292EFF">;</span></span>
<span class="line"><span style="color: #24292EFF">        }</span></span>
<span class="line"><span style="color: #24292EFF">    }</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #C2C3C5">// very simple ASCII key and IV</span></span>
<span class="line"><span style="color: #24292EFF">    $key </span><span style="color: #D32F2F">=</span><span style="color: #24292EFF"> </span><span style="color: #22863A">&quot;passwordDR0wSS@P6660juht&quot;</span><span style="color: #24292EFF">;</span></span>
<span class="line"><span style="color: #24292EFF">    $iv </span><span style="color: #D32F2F">=</span><span style="color: #24292EFF"> </span><span style="color: #22863A">&quot;password&quot;</span><span style="color: #24292EFF">;</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #C2C3C5">// hex encode the return value</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #6F42C1">echo</span><span style="color: #24292EFF"> </span><span style="color: #22863A">&quot;Result: &quot;</span><span style="color: #D32F2F">.</span><span style="color: #6F42C1">bin2hex</span><span style="color: #212121">(</span><span style="color: #6F42C1">mcrypt_cbc</span><span style="color: #212121">(</span><span style="color: #1976D2">MCRYPT_3DES</span><span style="color: #212121">,</span><span style="color: #6F42C1"> $key</span><span style="color: #212121">,</span><span style="color: #6F42C1"> $buffer</span><span style="color: #212121">,</span><span style="color: #6F42C1"> </span><span style="color: #1976D2">MCRYPT_ENCRYPT</span><span style="color: #212121">,</span><span style="color: #6F42C1"> $iv</span><span style="color: #212121">))</span><span style="color: #24292EFF">;	</span></span>
<span class="line"><span style="color: #24292EFF">}</span></span>
<span class="line"><span style="color: #D32F2F">?&gt;</span></span></code></pre><span style="display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#ffffff;color:#2f363c;font-size:12px;line-height:1;position:relative">PHP</span></div>



<figure class="wp-block-image size-large"><img decoding="async" src="/wp-content/uploads/2025/10/html_input.gif" alt=""/></figure>



<p>Then entered in my text (in this case I used &#8220;Test&#8221; in both)<br><br>Then I wrote up a sample in .NET to try to see if we had to massage the data or not:</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono-NL.ttf" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#FFFFFF"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#000000;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>using System;
using System.Security.Cryptography;
using System.Text;
using System.IO;

namespace TestBed {
    class Program {
        static void Main(string[] args) {
            byte[] key = Encoding.ASCII.GetBytes("passwordDR0wSS@P6660juht");
            byte[] iv = Encoding.ASCII.GetBytes("password");
            byte[] data = Encoding.ASCII.GetBytes("Test");
            byte[] enc = new byte&#91;0&#93;;
            TripleDES tdes = TripleDES.Create();
            tdes.IV = iv;
            tdes.Key = key;
            tdes.Mode = CipherMode.CBC;
            tdes.Padding = PaddingMode.Zeros;
            ICryptoTransform ict = tdes.CreateEncryptor();
            enc = ict.TransformFinalBlock(data, 0, data.Length);
            Console.WriteLine(Bin2Hex(enc));
            Console.ReadLine();
        }
        // my bin2hex implementation		
        static string Bin2Hex(byte[] bin) {
            StringBuilder sb = new StringBuilder(bin.Length * 2);
            foreach(byte b in bin) {
                sb.Append(b.ToString("x").PadLeft(2, '0'));
            }
            return sb.ToString();
        }
    }
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki light-plus" style="background-color: #FFFFFF" tabindex="0"><code><span class="line"><span style="color: #AF00DB">using</span><span style="color: #000000"> </span><span style="color: #267F99">System</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #AF00DB">using</span><span style="color: #000000"> </span><span style="color: #267F99">System</span><span style="color: #000000">.</span><span style="color: #267F99">Security</span><span style="color: #000000">.</span><span style="color: #267F99">Cryptography</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #AF00DB">using</span><span style="color: #000000"> </span><span style="color: #267F99">System</span><span style="color: #000000">.</span><span style="color: #267F99">Text</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #AF00DB">using</span><span style="color: #000000"> </span><span style="color: #267F99">System</span><span style="color: #000000">.</span><span style="color: #267F99">IO</span><span style="color: #000000">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #0000FF">namespace</span><span style="color: #000000"> </span><span style="color: #267F99">TestBed</span><span style="color: #000000"> {</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #0000FF">class</span><span style="color: #000000"> </span><span style="color: #267F99">Program</span><span style="color: #000000"> {</span></span>
<span class="line"><span style="color: #000000">        </span><span style="color: #0000FF">static</span><span style="color: #000000"> </span><span style="color: #0000FF">void</span><span style="color: #000000"> </span><span style="color: #795E26">Main</span><span style="color: #000000">(</span><span style="color: #0000FF">string</span><span style="color: #000000">[] </span><span style="color: #001080">args</span><span style="color: #000000">) {</span></span>
<span class="line"><span style="color: #000000">            </span><span style="color: #0000FF">byte</span><span style="color: #000000">[] </span><span style="color: #001080">key</span><span style="color: #000000"> = </span><span style="color: #001080">Encoding</span><span style="color: #000000">.</span><span style="color: #001080">ASCII</span><span style="color: #000000">.</span><span style="color: #795E26">GetBytes</span><span style="color: #000000">(</span><span style="color: #A31515">&quot;passwordDR0wSS@P6660juht&quot;</span><span style="color: #000000">);</span></span>
<span class="line"><span style="color: #000000">            </span><span style="color: #0000FF">byte</span><span style="color: #000000">[] </span><span style="color: #001080">iv</span><span style="color: #000000"> = </span><span style="color: #001080">Encoding</span><span style="color: #000000">.</span><span style="color: #001080">ASCII</span><span style="color: #000000">.</span><span style="color: #795E26">GetBytes</span><span style="color: #000000">(</span><span style="color: #A31515">&quot;password&quot;</span><span style="color: #000000">);</span></span>
<span class="line"><span style="color: #000000">            </span><span style="color: #0000FF">byte</span><span style="color: #000000">[] </span><span style="color: #001080">data</span><span style="color: #000000"> = </span><span style="color: #001080">Encoding</span><span style="color: #000000">.</span><span style="color: #001080">ASCII</span><span style="color: #000000">.</span><span style="color: #795E26">GetBytes</span><span style="color: #000000">(</span><span style="color: #A31515">&quot;Test&quot;</span><span style="color: #000000">);</span></span>
<span class="line"><span style="color: #000000">            </span><span style="color: #0000FF">byte</span><span style="color: #000000">[] </span><span style="color: #001080">enc</span><span style="color: #000000"> = </span><span style="color: #0000FF">new</span><span style="color: #000000"> </span><span style="color: #0000FF">byte</span><span style="color: #000000">&#91;</span><span style="color: #098658">0</span><span style="color: #000000">&#93;;</span></span>
<span class="line"><span style="color: #000000">            </span><span style="color: #267F99">TripleDES</span><span style="color: #000000"> </span><span style="color: #001080">tdes</span><span style="color: #000000"> = </span><span style="color: #001080">TripleDES</span><span style="color: #000000">.</span><span style="color: #795E26">Create</span><span style="color: #000000">();</span></span>
<span class="line"><span style="color: #000000">            </span><span style="color: #001080">tdes</span><span style="color: #000000">.</span><span style="color: #001080">IV</span><span style="color: #000000"> = </span><span style="color: #001080">iv</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">            </span><span style="color: #001080">tdes</span><span style="color: #000000">.</span><span style="color: #001080">Key</span><span style="color: #000000"> = </span><span style="color: #001080">key</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">            </span><span style="color: #001080">tdes</span><span style="color: #000000">.</span><span style="color: #001080">Mode</span><span style="color: #000000"> = </span><span style="color: #001080">CipherMode</span><span style="color: #000000">.</span><span style="color: #001080">CBC</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">            </span><span style="color: #001080">tdes</span><span style="color: #000000">.</span><span style="color: #001080">Padding</span><span style="color: #000000"> = </span><span style="color: #001080">PaddingMode</span><span style="color: #000000">.</span><span style="color: #001080">Zeros</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">            </span><span style="color: #267F99">ICryptoTransform</span><span style="color: #000000"> </span><span style="color: #001080">ict</span><span style="color: #000000"> = </span><span style="color: #001080">tdes</span><span style="color: #000000">.</span><span style="color: #795E26">CreateEncryptor</span><span style="color: #000000">();</span></span>
<span class="line"><span style="color: #000000">            </span><span style="color: #001080">enc</span><span style="color: #000000"> = </span><span style="color: #001080">ict</span><span style="color: #000000">.</span><span style="color: #795E26">TransformFinalBlock</span><span style="color: #000000">(</span><span style="color: #001080">data</span><span style="color: #000000">, </span><span style="color: #098658">0</span><span style="color: #000000">, </span><span style="color: #001080">data</span><span style="color: #000000">.</span><span style="color: #001080">Length</span><span style="color: #000000">);</span></span>
<span class="line"><span style="color: #000000">            </span><span style="color: #001080">Console</span><span style="color: #000000">.</span><span style="color: #795E26">WriteLine</span><span style="color: #000000">(</span><span style="color: #795E26">Bin2Hex</span><span style="color: #000000">(</span><span style="color: #001080">enc</span><span style="color: #000000">));</span></span>
<span class="line"><span style="color: #000000">            </span><span style="color: #001080">Console</span><span style="color: #000000">.</span><span style="color: #795E26">ReadLine</span><span style="color: #000000">();</span></span>
<span class="line"><span style="color: #000000">        }</span></span>
<span class="line"><span style="color: #008000">        // my bin2hex implementation		</span></span>
<span class="line"><span style="color: #000000">        </span><span style="color: #0000FF">static</span><span style="color: #000000"> </span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #795E26">Bin2Hex</span><span style="color: #000000">(</span><span style="color: #0000FF">byte</span><span style="color: #000000">[] </span><span style="color: #001080">bin</span><span style="color: #000000">) {</span></span>
<span class="line"><span style="color: #000000">            </span><span style="color: #267F99">StringBuilder</span><span style="color: #000000"> </span><span style="color: #001080">sb</span><span style="color: #000000"> = </span><span style="color: #0000FF">new</span><span style="color: #000000"> </span><span style="color: #267F99">StringBuilder</span><span style="color: #000000">(</span><span style="color: #001080">bin</span><span style="color: #000000">.</span><span style="color: #001080">Length</span><span style="color: #000000"> * </span><span style="color: #098658">2</span><span style="color: #000000">);</span></span>
<span class="line"><span style="color: #000000">            </span><span style="color: #AF00DB">foreach</span><span style="color: #000000">(</span><span style="color: #0000FF">byte</span><span style="color: #000000"> </span><span style="color: #001080">b</span><span style="color: #000000"> </span><span style="color: #AF00DB">in</span><span style="color: #000000"> </span><span style="color: #001080">bin</span><span style="color: #000000">) {</span></span>
<span class="line"><span style="color: #000000">                </span><span style="color: #001080">sb</span><span style="color: #000000">.</span><span style="color: #795E26">Append</span><span style="color: #000000">(</span><span style="color: #001080">b</span><span style="color: #000000">.</span><span style="color: #795E26">ToString</span><span style="color: #000000">(</span><span style="color: #A31515">&quot;x&quot;</span><span style="color: #000000">).</span><span style="color: #795E26">PadLeft</span><span style="color: #000000">(</span><span style="color: #098658">2</span><span style="color: #000000">, </span><span style="color: #A31515">&#39;0&#39;</span><span style="color: #000000">));</span></span>
<span class="line"><span style="color: #000000">            }</span></span>
<span class="line"><span style="color: #000000">            </span><span style="color: #AF00DB">return</span><span style="color: #000000"> </span><span style="color: #001080">sb</span><span style="color: #000000">.</span><span style="color: #795E26">ToString</span><span style="color: #000000">();</span></span>
<span class="line"><span style="color: #000000">        }</span></span>
<span class="line"><span style="color: #000000">    }</span></span>
<span class="line"><span style="color: #000000">}</span></span></code></pre><span style="display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#FFFFFF;color:#0d0d0d;font-size:12px;line-height:1;position:relative">C#</span></div>



<p>&#8220;<code>47794945c0230c3d</code>&#8221; Wouldn&#8217;t you know it! It worked like a charm!<br><br>Would have been nice if the Java -&gt; .NET solution had been that easy.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>PHP WebServices and C# / .NET SOAP Clients</title>
		<link>http://sanity-free.org/php_webservices_and_csharp_dotnet_soap_clients.html</link>
		
		<dc:creator><![CDATA[steve]]></dc:creator>
		<pubDate>Mon, 24 Jul 2006 18:00:44 +0000</pubDate>
				<category><![CDATA[C# Articles]]></category>
		<category><![CDATA[PHP Articles]]></category>
		<category><![CDATA[crossplatform]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[dotnet]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[soa]]></category>
		<category><![CDATA[webservices]]></category>
		<guid isPermaLink="false">http://dev.sanity-free.org/?p=142</guid>

					<description><![CDATA[Code Zulu Bind Maker is a project I started working on about 3 years ago. Its a stupid little app that configures game settings for Counter Strike. When I wrote it, version CS v1.6 was in beta, and everybody played version CS v1.5 (which was ever so different). Anyway I run a website that supports [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>Code Zulu Bind Maker is a project I started working on about 3 years ago. Its a stupid little app that configures game settings for Counter Strike. When I wrote it, version CS v1.6 was in beta, and everybody played version CS v1.5 (which was ever so different). Anyway I run a website that supports the app, and of course, its written in PHP / MySql (my poison of choice on the web).<br><br>The reason for the boring and seemingly pointless background is that ever since I wrote the app, I always wanted to integrate the website and application, but never really thought of a &#8220;good&#8221; way to do it. A couple days ago, I had some spare time and sat down to see how easy it would be to create some PHP webservices that I could easily consume in C#. I had been considering expanding the community aspect of the bind maker website into the application so that they&#8217;d work seamlessly together. I also wanted to add a common place that gaming communities could spend their time (which I had previously planned for just the website, but was thinking of the possibilities of bringing that into the app as well), and a PHP webservice combined with a C# windows app seemed like the best option.<br><br>C# web services (server side) are about as easy-as-it-gets to write. C#&#8217;s SOAP client is completely transparent (or I should say completely generated so you code just like you would use any other objects) and is completely brainless to use. Since I&#8217;d never done web service work in PHP, I started asking Mr. Google how it worked, and what would you now but that I stumbled across the <a href="http://sourceforge.net/projects/nusoap/">NuSOAP</a> library for PHP. It sure beat the heck out of writing all my WSDL files by hand, wrapping and unwrapping stupidly simple SOAP messages, and hacking everything very poorly.<br><br>My first PHP web service iteration was a simple &#8220;hello &lt;name&gt;&#8221; web method. It used a simple type (<code>xsd:string</code>) as its parameter and returned a simple type (again another <code>xsd:string</code>) as its return value and looked like this:</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers cbp-highlight-hover" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono-NL.ttf" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#24292eff;--cbp-line-number-width:calc(1 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(16, 41, 67, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#ffffff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#24292eff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly> /**
 * ProcessSimpleType method
 * &lt;strong>@param&lt;/strong> string $who name of the person we'll say hello to
 * &lt;strong>@return&lt;/strong> string $helloText the hello  string
 */
function ProcessSimpleType($who) {
	return "Hello $who";
}
</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki min-light" style="background-color: #ffffff" tabindex="0"><code><span class="line"><span style="color: #24292EFF"> </span><span style="color: #C2C3C5">/**</span></span>
<span class="line"><span style="color: #C2C3C5"> * ProcessSimpleType method</span></span>
<span class="line"><span style="color: #C2C3C5"> * &lt;strong&gt;</span><span style="color: #D32F2F">@param</span><span style="color: #C2C3C5">&lt;/strong&gt; string $who name of the person we&#39;ll say hello to</span></span>
<span class="line"><span style="color: #C2C3C5"> * &lt;strong&gt;</span><span style="color: #D32F2F">@return</span><span style="color: #C2C3C5">&lt;/strong&gt; string $helloText the hello  string</span></span>
<span class="line"><span style="color: #C2C3C5"> */</span></span>
<span class="line"><span style="color: #D32F2F">function</span><span style="color: #24292EFF"> </span><span style="color: #6F42C1">ProcessSimpleType</span><span style="color: #24292EFF">($who) {</span></span>
<span class="line"><span style="color: #24292EFF">	</span><span style="color: #D32F2F">return</span><span style="color: #24292EFF"> </span><span style="color: #22863A">&quot;Hello $who&quot;</span><span style="color: #24292EFF">;</span></span>
<span class="line"><span style="color: #24292EFF">}</span></span>
<span class="line"></span></code></pre><span style="display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#ffffff;color:#2f363c;font-size:12px;line-height:1;position:relative">PHP</span></div>



<p>NuSoap was great. It took care of all the nitty-gritty work that I had previously done myself. All it took was about 8 lines of code to set up the SOAP server and register the method and my types.</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers cbp-highlight-hover" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono-NL.ttf" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#24292eff;--cbp-line-number-width:calc(2 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(16, 41, 67, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#ffffff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#24292eff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>require_once("lib/nusoap/nusoap.php");
$namespace = "http://sanity-free.org/services";
// create a new soap server
$server = new soap_server();
// configure our WSDL
$server->configureWSDL("SimpleService");
// set our namespace
$server->wsdl->schemaTargetNamespace = $namespace;
// register our WebMethod
$server->register(
                // method name:
                'ProcessSimpleType', 		 
                // parameter list:
                array('name'=>'xsd:string'), 
                // return value(s):
                array('return'=>'xsd:string'),
                // namespace:
                $namespace,
                // soapaction: (use default)
                false,
                // style: rpc or document
                'rpc',
                // use: encoded or literal
                'encoded',
                // description: documentation for the method
                'A simple Hello World web method');
                
// Get our posted data if the service is being consumed
// otherwise leave this data blank.                
$POST_DATA = isset($GLOBALS&#91;'HTTP_RAW_POST_DATA'&#93;) 
                ? $GLOBALS&#91;'HTTP_RAW_POST_DATA'&#93; : '';

// pass our posted data (or nothing) to the soap service                    
$server->service($POST_DATA);                
exit();</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki min-light" style="background-color: #ffffff" tabindex="0"><code><span class="line"><span style="color: #D32F2F">require_once</span><span style="color: #24292EFF">(</span><span style="color: #22863A">&quot;lib/nusoap/nusoap.php&quot;</span><span style="color: #24292EFF">);</span></span>
<span class="line"><span style="color: #24292EFF">$namespace </span><span style="color: #D32F2F">=</span><span style="color: #24292EFF"> </span><span style="color: #22863A">&quot;http://sanity-free.org/services&quot;</span><span style="color: #24292EFF">;</span></span>
<span class="line"><span style="color: #C2C3C5">// create a new soap server</span></span>
<span class="line"><span style="color: #24292EFF">$server </span><span style="color: #D32F2F">=</span><span style="color: #24292EFF"> </span><span style="color: #D32F2F">new</span><span style="color: #24292EFF"> </span><span style="color: #1976D2">soap_server</span><span style="color: #24292EFF">();</span></span>
<span class="line"><span style="color: #C2C3C5">// configure our WSDL</span></span>
<span class="line"><span style="color: #24292EFF">$server</span><span style="color: #D32F2F">-&gt;</span><span style="color: #6F42C1">configureWSDL</span><span style="color: #212121">(</span><span style="color: #22863A">&quot;SimpleService&quot;</span><span style="color: #212121">)</span><span style="color: #24292EFF">;</span></span>
<span class="line"><span style="color: #C2C3C5">// set our namespace</span></span>
<span class="line"><span style="color: #24292EFF">$server</span><span style="color: #D32F2F">-&gt;</span><span style="color: #24292EFF">wsdl</span><span style="color: #D32F2F">-&gt;</span><span style="color: #24292EFF">schemaTargetNamespace </span><span style="color: #D32F2F">=</span><span style="color: #24292EFF"> $namespace;</span></span>
<span class="line"><span style="color: #C2C3C5">// register our WebMethod</span></span>
<span class="line"><span style="color: #24292EFF">$server</span><span style="color: #D32F2F">-&gt;</span><span style="color: #6F42C1">register</span><span style="color: #212121">(</span></span>
<span class="line"><span style="color: #24292EFF">                </span><span style="color: #C2C3C5">// method name:</span></span>
<span class="line"><span style="color: #24292EFF">                </span><span style="color: #22863A">&#39;ProcessSimpleType&#39;</span><span style="color: #212121">,</span><span style="color: #24292EFF"> 		 </span></span>
<span class="line"><span style="color: #24292EFF">                </span><span style="color: #C2C3C5">// parameter list:</span></span>
<span class="line"><span style="color: #24292EFF">                </span><span style="color: #6F42C1">array</span><span style="color: #24292EFF">(</span><span style="color: #22863A">&#39;name&#39;</span><span style="color: #D32F2F">=&gt;</span><span style="color: #22863A">&#39;xsd:string&#39;</span><span style="color: #24292EFF">)</span><span style="color: #212121">,</span><span style="color: #24292EFF"> </span></span>
<span class="line"><span style="color: #24292EFF">                </span><span style="color: #C2C3C5">// return value(s):</span></span>
<span class="line"><span style="color: #24292EFF">                </span><span style="color: #6F42C1">array</span><span style="color: #24292EFF">(</span><span style="color: #22863A">&#39;return&#39;</span><span style="color: #D32F2F">=&gt;</span><span style="color: #22863A">&#39;xsd:string&#39;</span><span style="color: #24292EFF">)</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">                </span><span style="color: #C2C3C5">// namespace:</span></span>
<span class="line"><span style="color: #24292EFF">                $namespace</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">                </span><span style="color: #C2C3C5">// soapaction: (use default)</span></span>
<span class="line"><span style="color: #24292EFF">                </span><span style="color: #1976D2">false</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">                </span><span style="color: #C2C3C5">// style: rpc or document</span></span>
<span class="line"><span style="color: #24292EFF">                </span><span style="color: #22863A">&#39;rpc&#39;</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">                </span><span style="color: #C2C3C5">// use: encoded or literal</span></span>
<span class="line"><span style="color: #24292EFF">                </span><span style="color: #22863A">&#39;encoded&#39;</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">                </span><span style="color: #C2C3C5">// description: documentation for the method</span></span>
<span class="line"><span style="color: #24292EFF">                </span><span style="color: #22863A">&#39;A simple Hello World web method&#39;</span><span style="color: #212121">)</span><span style="color: #24292EFF">;</span></span>
<span class="line"><span style="color: #24292EFF">                </span></span>
<span class="line"><span style="color: #C2C3C5">// Get our posted data if the service is being consumed</span></span>
<span class="line"><span style="color: #C2C3C5">// otherwise leave this data blank.                </span></span>
<span class="line"><span style="color: #24292EFF">$POST_DATA </span><span style="color: #D32F2F">=</span><span style="color: #24292EFF"> </span><span style="color: #6F42C1">isset</span><span style="color: #212121">(</span><span style="color: #6F42C1">$GLOBALS&#91;</span><span style="color: #22863A">&#39;HTTP_RAW_POST_DATA&#39;</span><span style="color: #6F42C1">&#93;</span><span style="color: #212121">)</span><span style="color: #24292EFF"> </span></span>
<span class="line"><span style="color: #24292EFF">                </span><span style="color: #D32F2F">?</span><span style="color: #24292EFF"> $GLOBALS&#91;</span><span style="color: #22863A">&#39;HTTP_RAW_POST_DATA&#39;</span><span style="color: #24292EFF">&#93; </span><span style="color: #D32F2F">:</span><span style="color: #24292EFF"> </span><span style="color: #22863A">&#39;&#39;</span><span style="color: #24292EFF">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C2C3C5">// pass our posted data (or nothing) to the soap service                    </span></span>
<span class="line"><span style="color: #24292EFF">$server</span><span style="color: #D32F2F">-&gt;</span><span style="color: #6F42C1">service</span><span style="color: #212121">(</span><span style="color: #24292EFF">$POST_DATA</span><span style="color: #212121">)</span><span style="color: #24292EFF">;                </span></span>
<span class="line"><span style="color: #D32F2F">exit</span><span style="color: #24292EFF">();</span></span></code></pre><span style="display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#ffffff;color:#2f363c;font-size:12px;line-height:1;position:relative">PHP</span></div>



<p>That was it. From visual studio I was then able to consume the web service by adding a web reference<br></p>



<figure class="wp-block-image size-large"><img decoding="async" src="/wp-content/uploads/2025/10/addref.gif" alt=""/></figure>



<p>This article was first written with visual studio 2005. Visual studio 2008 and 2010 no longer have the &#8220;Add Web Reference&#8221; menu item. Instead they have an option to add a service reference. Selecting this option ends up generating a WCF C# client proxy, but we&#8217;ll want to use the asmx style web service client proxy, so we&#8217;ll navigate to the add web reference dialog which is hidden deep inside Add Service Reference dialog.</p>



<aside class="wp-block-group sf-legend"><div class="wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained">
<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained">
<p><mark style="background-color:#000000" class="has-inline-color has-white-color">Visual Studio 2008 and 2010 Only</mark><br>Right click on the references folder, and select Add Service Reference<br></p>
</div></div>



<figure class="wp-block-image size-large"><img decoding="async" src="/wp-content/uploads/2025/10/svc-ref.png" alt=""/></figure>



<p>Click on the advanced button<br></p>



<figure class="wp-block-image size-large"><img decoding="async" src="/wp-content/uploads/2025/10/svc-adv.png" alt=""/></figure>



<figure class="wp-block-image size-large"><img decoding="async" src="/wp-content/uploads/2025/10/svc-awr.png" alt=""/></figure>
</div></aside>



<p>Finally click the Add Web Reference button<br></p>



<figure class="wp-block-image size-large"><img decoding="async" src="/wp-content/uploads/2025/10/refdiag.gif" alt=""/></figure>



<figure class="wp-block-image size-large"><img decoding="async" src="/wp-content/uploads/2025/10/webref.gif" alt=""/></figure>



<p>With the reference added, I put a button on my form, and added the following button click event handler:</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers cbp-highlight-hover" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono-NL.ttf" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(1 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(0, 0, 0, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#FFFFFF"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#000000;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>private void button1_Click(object sender, EventArgs e) {
    SimpleService svc = new SimpleService();
    string s = svc.ProcessSimpleType("steve");
    MessageBox.Show(s);
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki light-plus" style="background-color: #FFFFFF" tabindex="0"><code><span class="line"><span style="color: #0000FF">private</span><span style="color: #000000"> </span><span style="color: #0000FF">void</span><span style="color: #000000"> </span><span style="color: #795E26">button1_Click</span><span style="color: #000000">(</span><span style="color: #0000FF">object</span><span style="color: #000000"> </span><span style="color: #001080">sender</span><span style="color: #000000">, </span><span style="color: #267F99">EventArgs</span><span style="color: #000000"> </span><span style="color: #001080">e</span><span style="color: #000000">) {</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #267F99">SimpleService</span><span style="color: #000000"> </span><span style="color: #001080">svc</span><span style="color: #000000"> = </span><span style="color: #0000FF">new</span><span style="color: #000000"> </span><span style="color: #267F99">SimpleService</span><span style="color: #000000">();</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #001080">s</span><span style="color: #000000"> = </span><span style="color: #001080">svc</span><span style="color: #000000">.</span><span style="color: #795E26">ProcessSimpleType</span><span style="color: #000000">(</span><span style="color: #A31515">&quot;steve&quot;</span><span style="color: #000000">);</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #001080">MessageBox</span><span style="color: #000000">.</span><span style="color: #795E26">Show</span><span style="color: #000000">(</span><span style="color: #001080">s</span><span style="color: #000000">);</span></span>
<span class="line"><span style="color: #000000">}</span></span></code></pre><span style="display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#FFFFFF;color:#0d0d0d;font-size:12px;line-height:1;position:relative">C#</span></div>



<p>Ran my application, pressed the button (which in turn called the web service), and voilà I get a message box telling me Hello:<br><br></p>



<figure class="wp-block-image size-large"><img decoding="async" src="/wp-content/uploads/2025/10/hellosteve.gif" alt=""/></figure>



<p>That&#8217;s great! Completely useless, but great!<br><br>Now to get a little more complicated&#8230; I had planned on using complex data types that would be consumed by both PHP and .NET clients (A PHP SOAP client for the website, and .NET client for the windows application). It may sound stupid to have a PHP client when most likely I&#8217;d have access to the method directly, but the server that is going to host the web services is actually different than the &#8220;web presence&#8221; server I host my website on. Anyway, the test complex types I came up needed to look like simple structs (in C#) which would also be used in an array, and they looked something like this:</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers cbp-highlight-hover" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono-NL.ttf" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(0, 0, 0, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#FFFFFF"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#000000;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>public struct MySoapObject {
    public string Author;
    public string Name;
    public string Description;
    public string Text;
    public int VoteTotal;
    public int VoteCount;
}

MySoapObject[] soapObjects = new MySoapObject&#91;10&#93;;</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki light-plus" style="background-color: #FFFFFF" tabindex="0"><code><span class="line"><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">struct</span><span style="color: #000000"> </span><span style="color: #267F99">MySoapObject</span><span style="color: #000000"> {</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #001080">Author</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #001080">Name</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #001080">Description</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #001080">Text</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">int</span><span style="color: #000000"> </span><span style="color: #001080">VoteTotal</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">int</span><span style="color: #000000"> </span><span style="color: #001080">VoteCount</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #267F99">MySoapObject</span><span style="color: #000000">[] </span><span style="color: #001080">soapObjects</span><span style="color: #000000"> = </span><span style="color: #0000FF">new</span><span style="color: #000000"> </span><span style="color: #267F99">MySoapObject</span><span style="color: #000000">&#91;</span><span style="color: #098658">10</span><span style="color: #000000">&#93;;</span></span></code></pre><span style="display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#FFFFFF;color:#0d0d0d;font-size:12px;line-height:1;position:relative">C#</span></div>



<p>so I added the definitions in PHP using NuSOAP like this:</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers cbp-highlight-hover" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono-NL.ttf" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#24292eff;--cbp-line-number-width:calc(2 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(16, 41, 67, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#ffffff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#24292eff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>$server->wsdl->addComplexType(
    'MySoapObject',
    'complexType',
    'struct',
    'all',
    '',
    array(
        'Author' => array('name'=>'Author','type'=>'xsd:string'),
        'Name' => array('name'=>'Name','type'=>'xsd:string'),
        'Description' => array('name'=>'Description','type'=>'xsd:string'),
        'Text' => array('name'=>'Text','type'=>'xsd:string'),
        'VoteTotal' => array('name'=>'VoteTotal','type'=>'xsd:int'),
        'VoteCount' => array('name'=>'VoteCount','type'=>'xsd:int')
    )
);

$server->wsdl->addComplexType(
    'MySoapObjectArray',
    'complexType',
    'array',
    '',
    'SOAP-ENC:Array',
    array(),
    array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:MySoapObject[]')),
    'tns:MySoapObject'
);</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki min-light" style="background-color: #ffffff" tabindex="0"><code><span class="line"><span style="color: #24292EFF">$server</span><span style="color: #D32F2F">-&gt;</span><span style="color: #24292EFF">wsdl</span><span style="color: #D32F2F">-&gt;</span><span style="color: #6F42C1">addComplexType</span><span style="color: #212121">(</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #22863A">&#39;MySoapObject&#39;</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #22863A">&#39;complexType&#39;</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #22863A">&#39;struct&#39;</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #22863A">&#39;all&#39;</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #22863A">&#39;&#39;</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #6F42C1">array</span><span style="color: #24292EFF">(</span></span>
<span class="line"><span style="color: #24292EFF">        </span><span style="color: #22863A">&#39;Author&#39;</span><span style="color: #24292EFF"> </span><span style="color: #D32F2F">=&gt;</span><span style="color: #24292EFF"> </span><span style="color: #6F42C1">array</span><span style="color: #24292EFF">(</span><span style="color: #22863A">&#39;name&#39;</span><span style="color: #D32F2F">=&gt;</span><span style="color: #22863A">&#39;Author&#39;</span><span style="color: #212121">,</span><span style="color: #22863A">&#39;type&#39;</span><span style="color: #D32F2F">=&gt;</span><span style="color: #22863A">&#39;xsd:string&#39;</span><span style="color: #24292EFF">)</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">        </span><span style="color: #22863A">&#39;Name&#39;</span><span style="color: #24292EFF"> </span><span style="color: #D32F2F">=&gt;</span><span style="color: #24292EFF"> </span><span style="color: #6F42C1">array</span><span style="color: #24292EFF">(</span><span style="color: #22863A">&#39;name&#39;</span><span style="color: #D32F2F">=&gt;</span><span style="color: #22863A">&#39;Name&#39;</span><span style="color: #212121">,</span><span style="color: #22863A">&#39;type&#39;</span><span style="color: #D32F2F">=&gt;</span><span style="color: #22863A">&#39;xsd:string&#39;</span><span style="color: #24292EFF">)</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">        </span><span style="color: #22863A">&#39;Description&#39;</span><span style="color: #24292EFF"> </span><span style="color: #D32F2F">=&gt;</span><span style="color: #24292EFF"> </span><span style="color: #6F42C1">array</span><span style="color: #24292EFF">(</span><span style="color: #22863A">&#39;name&#39;</span><span style="color: #D32F2F">=&gt;</span><span style="color: #22863A">&#39;Description&#39;</span><span style="color: #212121">,</span><span style="color: #22863A">&#39;type&#39;</span><span style="color: #D32F2F">=&gt;</span><span style="color: #22863A">&#39;xsd:string&#39;</span><span style="color: #24292EFF">)</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">        </span><span style="color: #22863A">&#39;Text&#39;</span><span style="color: #24292EFF"> </span><span style="color: #D32F2F">=&gt;</span><span style="color: #24292EFF"> </span><span style="color: #6F42C1">array</span><span style="color: #24292EFF">(</span><span style="color: #22863A">&#39;name&#39;</span><span style="color: #D32F2F">=&gt;</span><span style="color: #22863A">&#39;Text&#39;</span><span style="color: #212121">,</span><span style="color: #22863A">&#39;type&#39;</span><span style="color: #D32F2F">=&gt;</span><span style="color: #22863A">&#39;xsd:string&#39;</span><span style="color: #24292EFF">)</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">        </span><span style="color: #22863A">&#39;VoteTotal&#39;</span><span style="color: #24292EFF"> </span><span style="color: #D32F2F">=&gt;</span><span style="color: #24292EFF"> </span><span style="color: #6F42C1">array</span><span style="color: #24292EFF">(</span><span style="color: #22863A">&#39;name&#39;</span><span style="color: #D32F2F">=&gt;</span><span style="color: #22863A">&#39;VoteTotal&#39;</span><span style="color: #212121">,</span><span style="color: #22863A">&#39;type&#39;</span><span style="color: #D32F2F">=&gt;</span><span style="color: #22863A">&#39;xsd:int&#39;</span><span style="color: #24292EFF">)</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">        </span><span style="color: #22863A">&#39;VoteCount&#39;</span><span style="color: #24292EFF"> </span><span style="color: #D32F2F">=&gt;</span><span style="color: #24292EFF"> </span><span style="color: #6F42C1">array</span><span style="color: #24292EFF">(</span><span style="color: #22863A">&#39;name&#39;</span><span style="color: #D32F2F">=&gt;</span><span style="color: #22863A">&#39;VoteCount&#39;</span><span style="color: #212121">,</span><span style="color: #22863A">&#39;type&#39;</span><span style="color: #D32F2F">=&gt;</span><span style="color: #22863A">&#39;xsd:int&#39;</span><span style="color: #24292EFF">)</span></span>
<span class="line"><span style="color: #24292EFF">    )</span></span>
<span class="line"><span style="color: #212121">)</span><span style="color: #24292EFF">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292EFF">$server</span><span style="color: #D32F2F">-&gt;</span><span style="color: #24292EFF">wsdl</span><span style="color: #D32F2F">-&gt;</span><span style="color: #6F42C1">addComplexType</span><span style="color: #212121">(</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #22863A">&#39;MySoapObjectArray&#39;</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #22863A">&#39;complexType&#39;</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #22863A">&#39;array&#39;</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #22863A">&#39;&#39;</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #22863A">&#39;SOAP-ENC:Array&#39;</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #6F42C1">array</span><span style="color: #24292EFF">()</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #6F42C1">array</span><span style="color: #24292EFF">(</span><span style="color: #6F42C1">array</span><span style="color: #24292EFF">(</span><span style="color: #22863A">&#39;ref&#39;</span><span style="color: #D32F2F">=&gt;</span><span style="color: #22863A">&#39;SOAP-ENC:arrayType&#39;</span><span style="color: #212121">,</span><span style="color: #22863A">&#39;wsdl:arrayType&#39;</span><span style="color: #D32F2F">=&gt;</span><span style="color: #22863A">&#39;tns:MySoapObject[]&#39;</span><span style="color: #24292EFF">))</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #22863A">&#39;tns:MySoapObject&#39;</span></span>
<span class="line"><span style="color: #212121">)</span><span style="color: #24292EFF">;</span></span></code></pre><span style="display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#ffffff;color:#2f363c;font-size:12px;line-height:1;position:relative">PHP</span></div>



<p>I defined the method in PHP that would take in an array of MySoapObjects, process them, and then return one MySoapObject that it had &#8220;processed&#8221;.<br><br>That method looked like this:</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers cbp-highlight-hover" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono-NL.ttf" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#24292eff;--cbp-line-number-width:calc(1 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(16, 41, 67, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#ffffff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#24292eff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>function ProcessMySoapObject($mySoapObjects) {
	$mso = $mySoapObjects&#91;3&#93;;
	$mso&#91;'Name'&#93; = "|||";
	return $mso;
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki min-light" style="background-color: #ffffff" tabindex="0"><code><span class="line"><span style="color: #D32F2F">function</span><span style="color: #24292EFF"> </span><span style="color: #6F42C1">ProcessMySoapObject</span><span style="color: #24292EFF">($mySoapObjects) {</span></span>
<span class="line"><span style="color: #24292EFF">	$mso </span><span style="color: #D32F2F">=</span><span style="color: #24292EFF"> $mySoapObjects&#91;</span><span style="color: #1976D2">3</span><span style="color: #24292EFF">&#93;;</span></span>
<span class="line"><span style="color: #24292EFF">	$mso&#91;</span><span style="color: #22863A">&#39;Name&#39;</span><span style="color: #24292EFF">&#93; </span><span style="color: #D32F2F">=</span><span style="color: #24292EFF"> </span><span style="color: #22863A">&quot;|||&quot;</span><span style="color: #24292EFF">;</span></span>
<span class="line"><span style="color: #24292EFF">	</span><span style="color: #D32F2F">return</span><span style="color: #24292EFF"> $mso;</span></span>
<span class="line"><span style="color: #24292EFF">}</span></span></code></pre><span style="display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#ffffff;color:#2f363c;font-size:12px;line-height:1;position:relative">PHP</span></div>



<p>The SOAP server registration:</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers cbp-highlight-hover" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono-NL.ttf" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#24292eff;--cbp-line-number-width:calc(1 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(16, 41, 67, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#ffffff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#24292eff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>$server->register(
    'ProcessMySoapObject',
    array('soapObjects'=>'tns:MySoapObjectArray'),
    array('return'=>'tns:MySoapObject'),
    $ns,
    false,
    'rpc',
    false,
    'Processes an array of MySoapObjects and returns one of them');</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki min-light" style="background-color: #ffffff" tabindex="0"><code><span class="line"><span style="color: #24292EFF">$server</span><span style="color: #D32F2F">-&gt;</span><span style="color: #6F42C1">register</span><span style="color: #212121">(</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #22863A">&#39;ProcessMySoapObject&#39;</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #6F42C1">array</span><span style="color: #24292EFF">(</span><span style="color: #22863A">&#39;soapObjects&#39;</span><span style="color: #D32F2F">=&gt;</span><span style="color: #22863A">&#39;tns:MySoapObjectArray&#39;</span><span style="color: #24292EFF">)</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #6F42C1">array</span><span style="color: #24292EFF">(</span><span style="color: #22863A">&#39;return&#39;</span><span style="color: #D32F2F">=&gt;</span><span style="color: #22863A">&#39;tns:MySoapObject&#39;</span><span style="color: #24292EFF">)</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">    $ns</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #1976D2">false</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #22863A">&#39;rpc&#39;</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #1976D2">false</span><span style="color: #212121">,</span></span>
<span class="line"><span style="color: #24292EFF">    </span><span style="color: #22863A">&#39;Processes an array of MySoapObjects and returns one of them&#39;</span><span style="color: #212121">)</span><span style="color: #24292EFF">;</span></span></code></pre><span style="display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#ffffff;color:#2f363c;font-size:12px;line-height:1;position:relative">PHP</span></div>



<p>And I did exactly the same as I did before&#8211;and added the web reference in visual studio to my project. This time not only did Visual Studio add the Service class and web method, it added the 2 data types I had defined in PHP on my SOAP server (actually, it just built the MySoapObject, and the array was left out because arrays are an implied data type).<br></p>



<figure class="wp-block-image size-large"><img decoding="async" src="/wp-content/uploads/2025/10/mysoap.gif" alt=""/></figure>



<figure class="wp-block-image size-large"><img decoding="async" src="/wp-content/uploads/2025/10/processmysoap.gif" alt=""/></figure>



<p>I changed my button click event in my windows form and added the following code:</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers cbp-highlight-hover" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono-NL.ttf" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(0, 0, 0, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#FFFFFF"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#000000;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>private void button1_Click(object sender, EventArgs e) {
    Services s = new Services();
    MySoapObject[] ms = new MySoapObject&#91;10&#93;;
    for(int i = 0; i &lt; ms.Length; i++) {
        ms&#91;i&#93; = new MySoapObject();
        ms&#91;i&#93;.Author = "Steve";
        ms&#91;i&#93;.Description = "The One that should be returned";
        ms&#91;i&#93;.Name = i.ToString();
        ms&#91;i&#93;.Text = "something something something " + i.ToString();
        ms&#91;i&#93;.VoteCount = i * 2;
        ms&#91;i&#93;.VoteTotal = (int)Math.Pow(ms&#91;i&#93;.VoteCount, 2);
    }
    MySoapObject retn = s.ProcessMySoapObject(ms);
    string output = "";
    output += retn.Author + "\t\t\r\n";
    output += retn.Description + "\t\t\r\n";
    output += retn.Name + "\t\t\r\n";
    output += retn.Text + "\t\t\r\n";
    output += retn.VoteCount.ToString() + "\t\t\r\n";
    output += retn.VoteTotal.ToString() + "\t\t\r\n";
    MessageBox.Show(output);
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki light-plus" style="background-color: #FFFFFF" tabindex="0"><code><span class="line"><span style="color: #0000FF">private</span><span style="color: #000000"> </span><span style="color: #0000FF">void</span><span style="color: #000000"> </span><span style="color: #795E26">button1_Click</span><span style="color: #000000">(</span><span style="color: #0000FF">object</span><span style="color: #000000"> </span><span style="color: #001080">sender</span><span style="color: #000000">, </span><span style="color: #267F99">EventArgs</span><span style="color: #000000"> </span><span style="color: #001080">e</span><span style="color: #000000">) {</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #267F99">Services</span><span style="color: #000000"> </span><span style="color: #001080">s</span><span style="color: #000000"> = </span><span style="color: #0000FF">new</span><span style="color: #000000"> </span><span style="color: #267F99">Services</span><span style="color: #000000">();</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #267F99">MySoapObject</span><span style="color: #000000">[] </span><span style="color: #001080">ms</span><span style="color: #000000"> = </span><span style="color: #0000FF">new</span><span style="color: #000000"> </span><span style="color: #267F99">MySoapObject</span><span style="color: #000000">&#91;</span><span style="color: #098658">10</span><span style="color: #000000">&#93;;</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #AF00DB">for</span><span style="color: #000000">(</span><span style="color: #0000FF">int</span><span style="color: #000000"> </span><span style="color: #001080">i</span><span style="color: #000000"> = </span><span style="color: #098658">0</span><span style="color: #000000">; </span><span style="color: #001080">i</span><span style="color: #000000"> &lt; </span><span style="color: #001080">ms</span><span style="color: #000000">.</span><span style="color: #001080">Length</span><span style="color: #000000">; </span><span style="color: #001080">i</span><span style="color: #000000">++) {</span></span>
<span class="line"><span style="color: #000000">        </span><span style="color: #001080">ms</span><span style="color: #000000">&#91;</span><span style="color: #001080">i</span><span style="color: #000000">&#93; = </span><span style="color: #0000FF">new</span><span style="color: #000000"> </span><span style="color: #267F99">MySoapObject</span><span style="color: #000000">();</span></span>
<span class="line"><span style="color: #000000">        </span><span style="color: #001080">ms</span><span style="color: #000000">&#91;</span><span style="color: #001080">i</span><span style="color: #000000">&#93;.</span><span style="color: #001080">Author</span><span style="color: #000000"> = </span><span style="color: #A31515">&quot;Steve&quot;</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">        </span><span style="color: #001080">ms</span><span style="color: #000000">&#91;</span><span style="color: #001080">i</span><span style="color: #000000">&#93;.</span><span style="color: #001080">Description</span><span style="color: #000000"> = </span><span style="color: #A31515">&quot;The One that should be returned&quot;</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">        </span><span style="color: #001080">ms</span><span style="color: #000000">&#91;</span><span style="color: #001080">i</span><span style="color: #000000">&#93;.</span><span style="color: #001080">Name</span><span style="color: #000000"> = </span><span style="color: #001080">i</span><span style="color: #000000">.</span><span style="color: #795E26">ToString</span><span style="color: #000000">();</span></span>
<span class="line"><span style="color: #000000">        </span><span style="color: #001080">ms</span><span style="color: #000000">&#91;</span><span style="color: #001080">i</span><span style="color: #000000">&#93;.</span><span style="color: #001080">Text</span><span style="color: #000000"> = </span><span style="color: #A31515">&quot;something something something &quot;</span><span style="color: #000000"> + </span><span style="color: #001080">i</span><span style="color: #000000">.</span><span style="color: #795E26">ToString</span><span style="color: #000000">();</span></span>
<span class="line"><span style="color: #000000">        </span><span style="color: #001080">ms</span><span style="color: #000000">&#91;</span><span style="color: #001080">i</span><span style="color: #000000">&#93;.</span><span style="color: #001080">VoteCount</span><span style="color: #000000"> = </span><span style="color: #001080">i</span><span style="color: #000000"> * </span><span style="color: #098658">2</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">        </span><span style="color: #001080">ms</span><span style="color: #000000">&#91;</span><span style="color: #001080">i</span><span style="color: #000000">&#93;.</span><span style="color: #001080">VoteTotal</span><span style="color: #000000"> = (</span><span style="color: #0000FF">int</span><span style="color: #000000">)</span><span style="color: #001080">Math</span><span style="color: #000000">.</span><span style="color: #795E26">Pow</span><span style="color: #000000">(</span><span style="color: #001080">ms</span><span style="color: #000000">&#91;</span><span style="color: #001080">i</span><span style="color: #000000">&#93;.</span><span style="color: #001080">VoteCount</span><span style="color: #000000">, </span><span style="color: #098658">2</span><span style="color: #000000">);</span></span>
<span class="line"><span style="color: #000000">    }</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #267F99">MySoapObject</span><span style="color: #000000"> </span><span style="color: #001080">retn</span><span style="color: #000000"> = </span><span style="color: #001080">s</span><span style="color: #000000">.</span><span style="color: #795E26">ProcessMySoapObject</span><span style="color: #000000">(</span><span style="color: #001080">ms</span><span style="color: #000000">);</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #001080">output</span><span style="color: #000000"> = </span><span style="color: #A31515">&quot;&quot;</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #001080">output</span><span style="color: #000000"> += </span><span style="color: #001080">retn</span><span style="color: #000000">.</span><span style="color: #001080">Author</span><span style="color: #000000"> + </span><span style="color: #A31515">&quot;</span><span style="color: #EE0000">\t\t\r\n</span><span style="color: #A31515">&quot;</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #001080">output</span><span style="color: #000000"> += </span><span style="color: #001080">retn</span><span style="color: #000000">.</span><span style="color: #001080">Description</span><span style="color: #000000"> + </span><span style="color: #A31515">&quot;</span><span style="color: #EE0000">\t\t\r\n</span><span style="color: #A31515">&quot;</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #001080">output</span><span style="color: #000000"> += </span><span style="color: #001080">retn</span><span style="color: #000000">.</span><span style="color: #001080">Name</span><span style="color: #000000"> + </span><span style="color: #A31515">&quot;</span><span style="color: #EE0000">\t\t\r\n</span><span style="color: #A31515">&quot;</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #001080">output</span><span style="color: #000000"> += </span><span style="color: #001080">retn</span><span style="color: #000000">.</span><span style="color: #001080">Text</span><span style="color: #000000"> + </span><span style="color: #A31515">&quot;</span><span style="color: #EE0000">\t\t\r\n</span><span style="color: #A31515">&quot;</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #001080">output</span><span style="color: #000000"> += </span><span style="color: #001080">retn</span><span style="color: #000000">.</span><span style="color: #001080">VoteCount</span><span style="color: #000000">.</span><span style="color: #795E26">ToString</span><span style="color: #000000">() + </span><span style="color: #A31515">&quot;</span><span style="color: #EE0000">\t\t\r\n</span><span style="color: #A31515">&quot;</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #001080">output</span><span style="color: #000000"> += </span><span style="color: #001080">retn</span><span style="color: #000000">.</span><span style="color: #001080">VoteTotal</span><span style="color: #000000">.</span><span style="color: #795E26">ToString</span><span style="color: #000000">() + </span><span style="color: #A31515">&quot;</span><span style="color: #EE0000">\t\t\r\n</span><span style="color: #A31515">&quot;</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #001080">MessageBox</span><span style="color: #000000">.</span><span style="color: #795E26">Show</span><span style="color: #000000">(</span><span style="color: #001080">output</span><span style="color: #000000">);</span></span>
<span class="line"><span style="color: #000000">}</span></span></code></pre><span style="display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#FFFFFF;color:#0d0d0d;font-size:12px;line-height:1;position:relative">C#</span></div>



<p>Compiled, ran and clicked.<br></p>



<figure class="wp-block-image size-large"><img decoding="async" src="/wp-content/uploads/2025/10/mysoapdiagresults.gif" alt=""/></figure>



<p>Simple, Easy, Can&#8217;t believe I never tried it before now!<br><br>This opened up a whole new world of opportunities in cross-platform distributed computing that I&#8217;d never exposed myself to before&#8230; what a wonderful thing!</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>A Battlefield 2 Rank Avatar Script in PHP</title>
		<link>http://sanity-free.org/battlefield_rank_avatar_script_in_php.html</link>
		
		<dc:creator><![CDATA[steve]]></dc:creator>
		<pubDate>Tue, 20 Sep 2005 18:00:18 +0000</pubDate>
				<category><![CDATA[PHP Articles]]></category>
		<category><![CDATA[battlefield2]]></category>
		<category><![CDATA[gaming]]></category>
		<category><![CDATA[php]]></category>
		<guid isPermaLink="false">http://dev.sanity-free.org/?p=107</guid>

					<description><![CDATA[This is a little departure from my typical topic. To cut a rather tedious and boring story short, I play Battlefield 2, which has a cool stats service that folks have been hacking with outside of the game (the game has a stats board built in, which stats board uses some pseudo web-services to obtain [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>This is a little departure from my typical topic.<br><br>To cut a rather tedious and boring story short, I play Battlefield 2, which has a cool stats service that folks have been hacking with outside of the game (the game has a stats board built in, which stats board uses some pseudo web-services to obtain game statistic info).<br><br>There are a multitude of server hosts out there that generate dynamic signature images with your game stats in them, so that you can look cool and show off how much time you actually waste online gaming, on every forum you frequent.<br><br>I decided to join the masses and write a script that pulls my users rank and score from the stats servers and returns an image that can be used as an avatar on most bulletin board systems out there. I had a size restriction on the server I wanted it for, so the images produced are 80&#215;80 and less than 6k in size.<br><br>Using the avatar script is pretty easy, you direct the image source URL to the server where you install the script (or you can just use the one here)<br></p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono-NL.ttf" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#FFFFFF"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#000000;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>html
&lt;img src="http://www.sanity-free.org/bf2rank/?pid=45647367">

bbCode
&#91;img&#93;http://www.sanity-free.org/bf2rank/?nick=&#91;OinK&#93;_MadHatter&#91;/img&#93;</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki light-plus" style="background-color: #FFFFFF" tabindex="0"><code><span class="line"><span style="color: #000000">html</span></span>
<span class="line"><span style="color: #000000">&lt;img src=&quot;http://www.sanity-free.org/bf2rank/?pid=45647367&quot;&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #000000">bbCode</span></span>
<span class="line"><span style="color: #000000">&#91;img&#93;http://www.sanity-free.org/bf2rank/?nick=&#91;OinK&#93;_MadHatter&#91;/img&#93;</span></span></code></pre></div>



<p>most bulletin board systems have places for you to link in a remote avatar, and one would add this same url w/ a name just as you would a normal image.<br><br>One annoying thing about most <code>bbcode</code> systems is that they require a valid image extension (.png, .jpg, .gif &#8230; ) on the URL inside the <code>[img][/img]</code> blocks (otherwise it just shows text inside the img blocks). To get your rank image to show up if you&#8217;re having troubles is to simply add an <code>&amp;avatar.jpg</code> to the end of the URL. The PHP code will ignore it, and the forum will think its a valid image and will show it correctly.<br><br>The resulting image looks like this:<br><img decoding="async" width="80" height="80" class="wp-image-94" style="width: 80px;" src="/wp-content/uploads/2025/10/bf2-rank-image-01.jpg" alt="rank image"></p>



<p>You can also specify a couple of options.</p>



<ul class="wp-block-list">
<li>adding <code>&amp;score</code> will display your global score at the top of the image.<br><img decoding="async" width="80" height="80" class="wp-image-98" style="width: 80px;" src="/wp-content/uploads/2025/10/bf2-rank-image-score.jpg" alt=""></li>



<li>adding <code>&amp;no_text</code> to the end of the URL will keep the text from being written on the image.<br><img loading="lazy" decoding="async" width="80" height="80" class="wp-image-97" style="width: 80px;" src="/wp-content/uploads/2025/10/bf2-rank-image-no_text.jpg" alt=""></li>



<li>adding <code>&amp;delta</code> to the end will show the difference in your progress between your last rank and your next one.<br><img loading="lazy" decoding="async" width="80" height="80" class="wp-image-96" style="width: 80px;" src="/wp-content/uploads/2025/10/bf2-rank-image-delta.jpg" alt=""></li>



<li>you can also combine any combination of them as well (this one is using <code>&amp;delta</code>, <code>&amp;no_text</code>, and <code>&amp;score</code> options).<br><img loading="lazy" decoding="async" width="80" height="80" class="wp-image-95" style="width: 80px;" src="/wp-content/uploads/2025/10/bf2-rank-image-delta-no_text.jpg" alt=""></li>
</ul>



<p><strong>EDIT Feb. 15 2006</strong>: since the last patch, I haven&#8217;t updated this article source code. <a href="https://gist.github.com/nullfx/9f8fa02103c0699585e1f4a7d3ca29d5#file-bf2rank-code-txt" target="_blank" rel="noreferrer noopener">HERE&#8217;S</a> the most recent version of the script. you can download the package and copy that over the script provided.<br><br><strong>EDIT March 20 2006</strong>: I updated the code to include nick name resolution (using <code>searchforplayers.aspx</code>). the link to the code above has that change in it. so you can use your player nick again instead of trying to find out your player ID.<br><br><strong>EDIT June 30 2006</strong>: I removed the source code from the article and repacked the download with everything you need.<br><br><strong>EDIT July 18 2006</strong>: I&#8217;ve added easy URLs for the rank avatars. for more info on that&#8211;and if you&#8217;d like to add them to your server&#8211;take a look at the thread in the forums <s>here</s>. <em>(forums no longer part of the site)</em><br><br><a href="https://github.com/nullfx/bf2rank" data-type="link" data-id="https://github.com/nullfx/bf2rank" target="_blank" rel="noreferrer noopener">Here&#8217;s the code for the script</a>. Edit: this for entertainment purposes only since nothing about this game exists anymore <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f62d.png" alt="😭" class="wp-smiley" style="height: 1em; max-height: 1em;" />.<br></p>



<p><a class="sf-downloads" href="https://github.com/nullfx/bf2rank" data-type="link" data-id="https://github.com/nullfx/bf2rank" target="_blank" rel="noreferrer noopener">Download source and resources here.</a></p>



<p></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
