Archive for December, 2016

Uncaught SoapFault exception: [Sender] SOAP-ERROR: Encoding: Violation of encoding rules


WTF?, why the hell is every PHP developer saying my webservice is returning Uncaught SoapFault exception: [Sender] SOAP-ERROR: Encoding: Violation of encoding rules – and there’s no problem with those using .NET, or parsing the XML response over HTTP GET/POST

Ok, let’s break down the problem.
1. It’s not a problem with PHP,it’s your WSDL, so here’s how to diagnose it.

Take this simple code snippet

$client = new SoapClient(“”);
$params = array (
“RegistrationNumber” => “TNZ6972”,
“username” => “**Your Username**”
$response = $client->__soapCall(‘Check’, array($params));

Now, take a copy of the WSDL, and save it as a text file, so you can edit it easily, i.e. , then using HTML style comments, take out everything you can until you get a minimum working version. – i.e. a call that returns “something“, not all the data, but “something

<s:complexType name=”Vehicle>
<s:element minOccurs=”0 maxOccurs=”1 name=”vehicleJson type=”s:string/>
<s:element minOccurs=”0 maxOccurs=”1 name=”vehicleXml type=”s:string/>
<s:element minOccurs=”0 maxOccurs=”1 name=”numberOfSeats type=”s:string/>
<s:element minOccurs=”0 maxOccurs=”1 name=”carValue type=”s:string/>
<s:element minOccurs=”0 maxOccurs=”1 name=”immobiliser type=”s:string/>
<!– <s:element minOccurs=”0 maxOccurs=”1 name=”vehicleData> … –>

I had a hunch it was the VehicleData object, since it was the most complex type in the response, so I commented that out – and I now had a minimum working version.

After that, I progressively commented out elements within the VehicleData type, until I got my maximum working version – i.e. as much data as possible without it breaking.

At that point, I hit upon this:

<s:element minOccurs=”0″ maxOccurs=”1″ name=”CarModel”> <s:complexType> <s:simpleContent> <s:extension base=”s:integer“> <s:attribute name=”type” type=”s:NCName” /> </s:extension> </s:simpleContent> </s:complexType> </s:element>

Which was the point at which the webservice stopped returning data, and starting throwing the Uncaught SoapFault exception: [Sender] SOAP-ERROR: Encoding: Violation of encoding rules – and it did look odd, since I new that “CarModel” should be a string, not an integer.

Looking at the underlying C# code, the error was obvious

public string Value {

There is no way that Value could both be a string and an integer, so I changed it to

public string Value {

Categories: Uncategorized

#Base64 decode using #SQL server #UDF


Base64 is a way to encode data into a limited character set, that can allow binary data to be displayed using print-friendly text. For example, if you wanted to represent an image as text, and store it in a database. It does bloat data, but it’s certainly handy when it comes to passing data around.

SQL server doesn’t have a handy function to convert base64 text back into it’s original form, so I decided to write this UDF below;

CREATE FUNCTION dbo.Base64Decode (@Base64 varchar(max))
RETURNS varchar(max)
DECLARE @TEXT AS varchar(max) ;
@TEXT = CAST( CAST( @Base64 as XML ).value(‘.’,’varbinary(max)’) AS varchar(max) );


Categories: Uncategorized

#Stuck #App #Roadside assistance in #Australia @stuck_app

Screen Shot 2016-12-03 at 14.05.58.png

Stuck is a new app for Australian drivers which you can download for iOS or Android via their website here;

Stuck is an on-demand service which calls local automotive experts to the rescue, saving you an annual insurance-style roadside assistance membership. Here’s how it works:

1. Share your required service and location with local, accredited automotive experts. The nearest available expert will arrive to help as soon as possible.

2. You are given the price upfront, which is usually about half the cost of a normal annual membership. Any extras can be added on if required (such as a new tyre).

3. Once your car problem is resolved, payment happens automatically without paperwork. Finally, you provide feedback to the automotive expert and get going!

From a technical point of view, it uses our Australian Car Registration API



Categories: Uncategorized

#MachineLearning using #Microsoft Azure

"1+1=3" handwritten with white chalk on a blackboard

Me: Azure , what is 1 + 1 ?

Azure: It’s 1.999999999992212

Me: No it’s not.

Azure: Come on, I’m almost right!

I’ve just been playing with the Azure Machine Learning Studio, to see if it could be accurate enough for practical applications. The most simple example I could think of was a model where it was given 1,000 examples of one number, followed by a second number which was one greater.


You can see the model in the Cortana Intellegence Gallery here

Interestingly, the result is not perfect as would be expected, but it goes wrong in a way that only a machine would think is close to the correct answer.




Categories: Uncategorized

#Verify a #BankAccount via an #API


If you process large volumes of payments, then you will need to be able to quickly and cheaply check that the payment you are about to make is going to a valid bank account, or else it will delay payment to your supplier / employee / or affiliate, this API allows you to check each account for 3p / 4¢ – using the same technology as used by Stripe.


Getting started

The API endpoint is located at

It accepts GET / POST and SOAP requests, and returns either a HTTP 500 error with textual description on error, or JSON embedded in XML in the case of a valid response, similar to as follows:

<string xmlns=””&gt;

 “id”: “ba_19LxhvI1fputaiwwXEZeaGit”,
 “object”: “bank_account”,
 “account”: “acct_198SNII1fxutaiww”,
 “account_holder_name”: null,
 “account_holder_type”: null,
 “bank_name”: “BOI UK PLC”,
 “country”: “GB”,
 “currency”: “gbp”,
 “default_for_currency”: true,
 “fingerprint”: “YiMK5qcuDQXGocsn”,
 “last4”: “2674”,
 “metadata”: {
 “routing_number”: “90-49-74”,
 “status”: “new”,
 “name”: null


Countries supported by this API are as follows;

Country code
IE Ireland
GB United Kingdom
AU Australia
CA Canada
DK Denmark
FI Finland
FR France
JP Japan
NO Norway
SG Singapore
ES Spain
SE Sweden
AT Austria
BE Belgium
DE Germany
HK Hong Kong
IT Italy
LU Luxembourg
NL Netherlands
PT Portugal

The API also includes an endpoint for programmatically retrieving the remaining credits associated with an API Key, called  GetRemainingCredit returning data such as;

<int xmlns=””>98</int&gt;

C# (.NET) implementation

Here is a step by step guide to writing a simple C# client

  • Open Visual Studio
  • Press File > New > Project
  • Select Console Application – Visual C#
  • Press OK
  • Right Click on the project in Solution Explorer
  • Select Add > Service Reference
  • Click Advanced
  • Click Add Web Reference
  • Enter “” into the URL
  • Press Add Reference
  • Click Tools > NuGet Package Manager > Package Manager Console
  • Type “Install-Package Newtonsoft.JSON” into the Package Manager Console window
  • Now, enter the following code (Replacing the API KEY)
       static void Main(string[] args)


           var strAPIKey = “Your API key here“;

           var bank = new com.verifybankaccount.www.API();

           Console.WriteLine(“Enter the 2 letter country code:”);

           var strCountry = Console.ReadLine();

           Console.WriteLine(“Enter the Bank sort code:”);

           var strSortCode = Console.ReadLine();

           Console.WriteLine(“Enter the Bank account number:”);

           var strAccountNumber = Console.ReadLine();



               var strJson = bank.VerifyBankAccount(strCountry, strSortCode,

                                       strAccountNumber, strAPIKey);

               var jObject = Newtonsoft.Json.Linq.JObject.Parse(strJson);

               Console.WriteLine(“This bank is ” + jObject[“bank_name”]);


           catch(Exception ex)






PHP Implementation

The following implementation uses the HTTP GET version of the webservice, you could use $soapclient as an alternative implementation. Please note that you should never pass bank account details over an unsecure connection so this code should be run either on localhost or on a suitably secured HTTPS webserver.

You will have to replace the APIKey below


$country = $_GET[“country”];

$sortcode = $_GET[“sortcode”];

$accountNumber = $_GET[“accountNumber”];

$url = “ /VerifyBankAccount?”;

$url .= “Country=” . $country;

$url .= “&SortCode=” . $sortcode;

$url .= “&AccountNumber=” . $accountNumber;

$url .= “&ApiKey={{Your API Key}}“;

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$xmlData = curl_exec($ch);



if ($xml) {

$json = json_decode($xml);









Categories: Uncategorized