Posts from September 2007

PHP: SimpleXML + SOAP

Posted on in PHP & and tagged PHP, SimpleXML & SOAP View Comments

Recently after getting into XML parsing with PHP and realising how hard most of the functions were to use, I decided to put it down and that i was going to require PHP5 for all my projects. Great i thought, SOAP, PHP’s got a SOAPClient class!

Personally i didnt like the Soap class, I’m happy to hardcode the values i send to the server,  But i want to read the returned XML easily.

I looked around, and found SimpleXML, And i like it!, It  worked well with all the sniplets of XML i gave it.. Well, Until i actually used it on some live data!

Suddenly SimpleXML refuses to parse the SOAP reply…

Heres a example of XML SimpleXML didnt like:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetProviders xmlns="http://hostname/" />
</soap:Body>
</soap:Envelope>

See any problem? Looks valid to me!

The cause of it not parsing though? SimpleXML doesnt like any colons(:) in tagnames or attribute names! If its contained within the value of the tag or attribute its ok though.

So, What can i do? A Mass-replace of all colons? That’d potentially destroy my source data..

I came up with this short snipplet of PHP regular expressions to strip out any colons in the tags/attributes:

$out = preg_replace('|<([/\w]+)(:)|m','<$1',$in);
$out = preg_replace('|(\w+)(:)(\w+=\")|m','$1$3',$out);

The result after this has been done:

<?xml version="1.0" encoding="utf-8"?>
<soapEnvelope xmlnsxsi="http://www.w3.org/2001/XMLSchema-instance" xmlnsxsd="http://www.w3.org/2001/XMLSchema" xmlnssoap="http://schemas.xmlsoap.org/soap/envelope/">
<soapBody>
<GetProviders xmlns="http://hostname/" />
</soapBody>
</soapEnvelope>

As you can see, the general gyst of the document is there, and its parsable,  just without the colons where simpleXML cant handle them.

Dovecot: ERR No INBOX for user

Posted on in General & and tagged dovecot & stupidities View Comments

Did something stupid a few days ago, After Opera 9.5 Alpha did something stupid with my email, I decided to clear out all email on my server..

Not a hard thing to do.. SSH to server, echo > ~/mail/username Check the list with the ‘mail‘ app, Yep all fine.. emails cleared; Then went out for a few days.

Come back today and i have no email? Strange, I send myself a test message, Doesnt turn up in my POP3 inbox.. SSH in, whoa, 92 messages on the server (using the ‘mail‘ command again), Why isnt it coming through POP3 then?

Started investigating, grabed telnet and connected to the mail server, Here’s what i got:

+OK dovecot ready.
USER my_username
+OK
PASS my_super_secret
+OK Logged in.
-ERR No INBOX for user.

Yep.. Somethings screwed on the server, But what? I didnt touch anything!

After a lot of screwing around and re-setting permissions and all that, I found the error, Can you see the error?

Dovecot mail error

No, I’m not supprised if you cant see it, It didnt hit me at first either, Especially when  mail was showing all my mail correctly.

Turned out, Dovecot doesnt like the new line at the start of the file, It bails out thinking its not a valid inbox…. removed the new line and everythings off and running fine again. Shame i bothered the hosts support a few hours ago, But at least i had fixed it before they started pulling their hair out :)

MSN: FailedAuthentication Profile accrual is required

Posted on in General & and tagged dmsn, MSN & PHP View Comments

I’m writing a PHP MSN ‘framework’ based on MSNP15 at present, This evening the SSO authentication failed with the following message: (Apologies to not having exact XML)

wsse FailedAuthentication
Failure Code: Profile accrual is required 

The cause? MSN has updated the protocol? Nope, I needed to update the profile for that account, upon logging into MSN messenger with it i was asked to fill out my Birthyear and Country. Upon entering those details in its once again working nicely.

Why blog about this? Well, Why not? Google didnt have any comments for the given failure code, might as well get an explanation out there :)