return to I Love My Journal
A Little Closer to Center...
Musings about Life, Linux, and Latter-day Saints.
Pages
About Me
Links


Tags
PERSONAL 520
SPIRITUAL 416
LDS 312
BOOK OF MORMON 237
SCRIPTURES 154
STUDIO-JOURNEY 129
RELIGION 112
LINUX 79
COMPUTERS 65
LIFE 60
GENERAL CONFERENCE 46
GENTOO 39
MISCELLANEOUS 37
MUSIC 37
PROGRAMMING 33
CARS 29
MICROSOFT 23
FAMILY 23
AUDIO 21
I LOVE MY JOURNAL 18
FUN 15
CHILDREN 12
CURRENT EVENTS 10
NATURE'S WAY 10
VIDEO 9
DRM 9
CONEXM 7
BABBLINGS 7
PROVO CITY CENTER TEMPLE 6
FRIENDS 6
HEROD THE FINK 5
GAMES 5
COMPUTER HARDWARE 5
DRUMS 4
HAND OF GOD 3
ADVERSITY 3
KDENLIVE 3
AUDIO HARDWARE 3
GENERAL INSANITY 3
STUDIO 3
THANKS4GIVING 2
CATS 2
MY JOURNAL 1
POETRY 1
FOREVERGREEN 1
EVERYDAY THOUGHTS 1
GOSPEL 1
PARENTING 1
YOUTH CONFERENCE 1
CHURCH NOTES 1
POLITICS 1


RSS Feed

RSS FeedSubscribe!
Fri - Feb 13, 2009 : 03:08 pm
confused
   rated 30 times
>>next>>
<<previous<<
SOAP, PHP, and WSDL
I spent pretty much all of yesterday trying in vain to write a soap client to connect to a web service provided by our new partner in Green Bay, WI.

After about 6 solid hours of getting the same error, a great programmer and acquaintence of mine, Jared Smith gave me a quick tip on how to fix it.

Before I get to the fix, let me say that first, I decided to use the internal SOAP extension native to PHP 5, and therefore read a fairly large amount of documentation, trying to get it to connect.

The error I was getting was this:

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://services.somewhere.com/orderdog/order.asmx' : Premature end of data in tag html line 3 in /var/www/somewhere/main/grab_product.php:3 Stack trace: #0 /var/www/somewhere/main/grab_product.php(3): SoapClient->SoapClient('http://services...') #1 {main} thrown in /var/www/somewhere/main/grab_product.php on line 3

The more I googled, the more frustrated I became because nothing out there seemed to give me any direction as to what this error meant - and what's worse is that PHP's documentation (comments included) seemed to be just as helpless.

I was using one line of code, and I had previously verified that PHP was indeed compiled with soap support.

Here was the one line of code:

$webservice = new SoapClient("http://services.somewhere.com/orderdog/order.asmx");

Yup...  Not even that worked.

So, I went to my faithful UPHPU IRC group and posed the question.  Jared Smith (jsmith) was quick to, not only answer my question, but at the same time, quick to write a 100-line script detailing pretty much everything that I needed to know to build a basic web service client (SOAP) app in PHP.  There's open source for ya.  What a great group of people.

So, the fix to the problem noted above was summed up in 5 more characters of code, which EASILY could have been included in the documentation for SOAP with PHP:

$webservice = new SoapClient("http://services.somewhere.com/orderdog/order.asmx?WSDL");

If you don't look closely, you won't even notice the difference - and I honestly have no idea why the extra characters are necessary - or even if they are universally necessary.  All I know is that they made my app connect successfully.

*sigh*

I have no idea why some of the littlest things in code which make it impossible for the code to function at all, aren't documented anywhere.

But, anyway, that's how you solve the problem - or at least one way to solve it - and I know that if it wasn't for Jared, I would still be banging my head on this problem today.

Open Source FTW.
Comment by Exotux on Aug. 11, 2009 @ 02:51 am
Thank you very much !
Comment by Ronald on Aug. 25, 2009 @ 02:08 am
Great!

I just got that same error. So I added the ?WDSL to my URL and now it works.

Thanks for sharing.
Comment by Rik on Sep. 19, 2009 @ 08:18 am
Dang! Thanks, great post, you just ended hours of searching and frustration.
Comment by Tan-Tan on Oct. 14, 2009 @ 03:51 am
 
I try to release a PHP WSDL BPEL engine, base on PHP CLI application server.
Any help would be appreciated.
 
http://code.google.com/p/ezerphp/
Comment by Mike D. on Oct. 30, 2009 @ 08:09 am
6 HOURS and that was it! YARGH! Congrats on figuring it out though :D 

 

p.s. making me spell words to post... ghrasidojasdjksladjsad
Comment by Mehran on Nov. 01, 2009 @ 11:21 pm
Thanks alot
Comment by Gareth Poole on Dec. 22, 2009 @ 03:22 am
lifesaver! Thanks! 
Comment by Stephen on Dec. 22, 2009 @ 10:48 pm
You are the man... thanks, you saved my life on this one.
Comment by bezh on Feb. 23, 2010 @ 07:37 am
thanx. that append ?WSDL was important 
Comment by dun on Apr. 21, 2010 @ 11:29 pm
Thank you my man, me too baffled why it "?wsdl" is not well documented
Comment by Sb on Jun. 11, 2010 @ 03:01 pm
Thanks for sharing, simple but important oversight.
Comment by mike on Jun. 21, 2010 @ 08:36 am
Saved my bacon, AND my sanity today as well. Thanks for posting this solution.
Comment by Łukasz Skowroński on Jul. 19, 2010 @ 05:05 pm
Thanks from Poland :)
Comment by Amitab Roy on Sep. 01, 2010 @ 07:04 am
 Thanks...it really helped!
Comment by christian on Nov. 22, 2010 @ 07:42 am
 Many thanks for sharing this, saved many hours of searching
Comment by Francois on Nov. 29, 2010 @ 04:53 am
Gosh man you saved my life! Thank you really much for that and agreed on everything you said! Soap doc should be re-done!
Comment by kevin on Dec. 04, 2010 @ 04:48 pm
Thank you thank you thank you!
Comment by Mike Taylor on Jan. 08, 2011 @ 02:17 am
Wow. Thank you. Saved me a lot of heart-ache. ?WDSL worked for me.
Comment by El Pix on Jan. 24, 2011 @ 08:05 am
Thanks for sharing, it works :)
Comment by Ryan Florence on Feb. 04, 2011 @ 03:31 pm
Thank you x 1 million.  I only spent two hours staring at the same error, both PHP and Ruby were freaking out.  

From the command line, `curl` was the only thing keeping me from telling the feed provider they need to fix something :) 

(The opposite of left can also be "arrived")
Comment by anubhav on Mar. 03, 2011 @ 12:59 am
I did the same thing added a ?wsdl at the end of the url yet it does not work but it works from my other system..

 

can it be a url issue

or a php configuraiton issue.
Comment by Rafael on Mar. 15, 2011 @ 07:52 am
This tip didn't work for me. =\ 
Comment by artwells on Mar. 21, 2011 @ 12:55 pm
It's horrible to imagine how long it would have taken me to figure this one out.  Thank you so much for putting the answer where search engines could pick it up.

Definitely, this should be part of the php docs 
Comment by anonymous on Mar. 23, 2011 @ 12:32 pm
 IT SAVED ME!!
Comment by Richard Turner on Apr. 09, 2011 @ 08:02 am
spent nearly 2hours on this, had same problem before but couldn't remember what it was, thank you!!!!!

 

Thank you again

 

p.s.

 

"What's the light-source in the night-sky? (not the sun, but the...?)"

it's still the sun, the moon reflects the sun's light.
Comment by elyoukey on Apr. 20, 2011 @ 10:12 am
thanks a lot

/me add 1 coin in the bucket
Comment by Aromal on Apr. 26, 2011 @ 06:02 am
Thanks for sharing, it works :)
Comment by Edu on May. 12, 2011 @ 03:37 pm
Excelent!!! works!
Comment by matt on May. 31, 2011 @ 11:09 pm
Thanks heaps!! Had this problem bugging me for hours!!

 
Comment by Peter Mills on Aug. 01, 2011 @ 07:25 pm
Thanks heaps - so simple but so hard to find.  From the sound of it you've saved me hours on this.  And you're right, such a simple thing should be documented somewhere!
Comment by Michael Clark on Aug. 11, 2011 @ 03:35 pm
It's a Microsoft thing. Open http://msdn.microsoft.com/en-us/library/bb515342.aspx and search for "wsdl", you'll find it.
Comment by Michael Clark on Aug. 11, 2011 @ 03:44 pm
http://msdn.microsoft.com/en-us/library/ee767684.aspx - "Although the ASMX column shows the service with an .asmx extension, the actual URL must include the ?wsdl URL option, for example, Admin.asmx?wsdl." Couldn't have said it better. IT IS DOCUMENTED.
Comment by Carlos on Sep. 15, 2011 @ 07:16 am
So simple! I got almost half a hour trying to understand what i did wrong...thanks for the post ;)
Comment by Adaptoid on Sep. 21, 2011 @ 05:15 am
I just spent the better part of the morning with this exact same problem... thank you for this solution you just saved me hours and hours of bashing my head against my desk.
Comment by Mike on Nov. 03, 2011 @ 08:00 pm
 You RULE, sir. Thank you SO much.
Comment by enlil on Dec. 14, 2011 @ 10:25 am
Many thanks!!!
Comment by serhan on Dec. 30, 2011 @ 06:31 am
Awesome man
Comment by Amit Karanjawala on Jan. 14, 2012 @ 09:58 am
Thanks buddy. I was facing the same problem..searched the net..found your post and got it fixed :)
Comment by Dita on Jan. 14, 2012 @ 01:53 pm
many thanks ... saved so much time :)
Comment by Alex Rodin on Feb. 09, 2012 @ 07:12 am
thank you!
Comment by amitpatil on Feb. 14, 2012 @ 01:27 am
I am already using ?WSDL in url but still no luck :( m still fighting
Comment by Jaco Smit on Mar. 05, 2012 @ 04:53 am
Still Struggling.

 I have had a feed up and running and since my server at Hosting Company was Upgraded, I can not connect anymore.

PHP 5.3.3 is a bit of a Bitch...

What is Deprecated other than "= & new SoapClient()" to "= new SoapClient()"??

 

Please Help-elep-elep-elep.
Comment by Zeph on Apr. 30, 2012 @ 02:31 pm
Thanks man! These four characters made the difference!

Than you so much! :)

 
Comment by e-hoster on Jun. 29, 2012 @ 10:11 am
After quite a long time trying I found a couple of things I needed to change to get this to work:

The first was to add the wsdl thank you for your help on that one.

The second was to change new SoapClient to new nusoap_client

This then got everything working correctly.

 

Best wishes

James
Comment by Donnet, Sylvain on Jul. 01, 2012 @ 01:07 am
+1

Thanks to you ! Saves me a lot of time !
Comment by sandrapa on Jul. 03, 2012 @ 06:44 pm
I just have to use new nusoap_client and it works!!! Thanks e-hoster!!!! I had spent a lot of time and now I can't believe it's done :-)
Comment by Armando Borge on Jul. 13, 2012 @ 05:26 pm
Thanks! This really helps me... 
Comment by Jason on Jul. 31, 2012 @ 08:55 pm
Thank you - thank you - thank you for posting this...  
Comment by Raman on Dec. 17, 2012 @ 02:36 pm
Thanks,

It was a grt grt help, I had same problem and slved using your suggestion 
Comment by soappy on Feb. 20, 2013 @ 11:32 pm
 thank you! That solved my three days problem!
Comment by Salman on Mar. 04, 2013 @ 03:25 pm
Thanks for saving my life, time and the frustration that was about to build up!

 
Comment by anonymous on Aug. 20, 2013 @ 03:23 am
rftgrdtghgh
Comment by Jason Ulrich on Mar. 27, 2015 @ 09:46 am
THANK YOU!  THANK YOU!  THANK YOU!