Web services

nbkx10mx

New Member
Messages
8
Reaction score
0
Points
0
Hey.

I need to develop and web service, is it possible to do at x10hosting, and if it is, how can I do it?

Thanks.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
That's one of the most open-ended questions I've seen in awhile. When it comes to technical, open ended questions are just about the worst, second perhaps only to vague questions. Read my sig for how to improve the question.

Start with the hosting plan comparison page to see which plan meets your requirements. As for how to do it, you'll just have to learn how to program. There's plenty of information online, so get to searching. Set up your own development server so you have the necessary control over it, and can run an interactive debugger.
 
Last edited:

kloadx10

New Member
Messages
24
Reaction score
0
Points
0
Ya as misson said it just set up a local server on your computer do all the editing and analyzing on it and finally test each page on the online server, but there is another catch some php extensions are available on some servers and on some are not so you have to make sure there is a way that your script first checks if the extension is available or not and if not then throw a user friendly message error else run the script. My main point is your have to check your services on different types of servers whether paid or free.
 

nbkx10mx

New Member
Messages
8
Reaction score
0
Points
0
Hey, guys. Thanks for responding.

Let me rephrase. I need to know if this specific hostile(x10) supports writing web services in PHP, or any other script for that matter. The reason I'm asking is because I did find some examples on the web, and they don't seem to work here (PHP parser errors).

Thanks.

---------- Post added at 10:23 AM ---------- Previous post was at 10:21 AM ----------

"hostile"->"hosting", for some reason editing doesn't work.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
The reason I'm asking is because I did find some examples on the web, and they don't seem to work here (PHP parser errors).

Thanks.

If they have Parser errors, they shouldn't work anywhere.

Without an example of what you want to do but that doesn't work on x10hosting, there is no way we can help you.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
In particular, we require example code that's complete, concise and representative. Have you read the links in my sig (and now this post) yet?
 
Last edited:

nbkx10mx

New Member
Messages
8
Reaction score
0
Points
0
Well this is the example I found on the net:

Code:
[COLOR=#6633FF]<?php[/COLOR]
[COLOR=#6633FF]$requestPayload = <<<XML[/COLOR]
[COLOR=#6633FF]<calculate>[/COLOR]
[COLOR=#6633FF]<param1>100</param1>[/COLOR]
[COLOR=#6633FF]<param2>43</param2>[/COLOR]
[COLOR=#6633FF]<param3>add</param3>[/COLOR]
[COLOR=#6633FF]</calculate>[/COLOR]
[COLOR=#6633FF]XML;[/COLOR]

[COLOR=#6633FF]try{[/COLOR]
[COLOR=#6633FF]$message = new WSMessage($requestPayload,[/COLOR]
[COLOR=#6633FF]            array("to" => "http://localhost:81/CalculatorService.php"));[/COLOR]
[COLOR=#6633FF]$client = new WSClient();[/COLOR]
[COLOR=#6633FF]$response = $client->request($message);    [/COLOR]
[COLOR=#6633FF]echo "Answer : $response->str";[/COLOR]
[COLOR=#6633FF]}[/COLOR]
[COLOR=#6633FF]catch (Exception $e){   [/COLOR]
[COLOR=#6633FF]if ($e instanceof WSFault){[/COLOR]
[COLOR=#6633FF]  $fault = $e;[/COLOR]
[COLOR=#6633FF]  printf("Soap Fault received. Code: '%s' .Reason: '%s'\n",[/COLOR]
[COLOR=#6633FF]                  $fault->code, $fault->reason);[/COLOR]
[COLOR=#6633FF]}else{[/COLOR]
[COLOR=#6633FF]  printf("Exception occurred. Message: '%s'\n", $e->getMessage());[/COLOR]
[COLOR=#6633FF]}[/COLOR]
[COLOR=#6633FF]}[/COLOR]
[COLOR=#6633FF]?>[/COLOR]
The error I got is:

Fatal error: Class 'WSMessage' not found in /home/nbkx10mx/public_html/WebServices/webservice.php on line 11
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
1. That is not a Parse error

2. That script assumes you have other files etc installed. The site you got that from should tell you where to get the files.
 

nbkx10mx

New Member
Messages
8
Reaction score
0
Points
0
Well they mention something about WSF/PHP extention and how to install it on local apache server, but the question is can that extension be installed here and how? As far as I can see I can't configure the apache server here.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
If it is merely files that you have to include into your PHP script, then you should be able to do it.

If it requires adding to or modifying the PHP/Litespeed (not Apache) set up, the answer is no. I don't know of any free hosting service that allows you to mess with the system at that level.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
It looks like WSF/PHP is a PHP extension, requiring compilation (which in turn requires shell access to the server or another computer running the exact same OS release and with the same configuration) and to be loaded into the PHP process itself. Neither shell access nor extension loading is allowed on free hosting for security and performance reasons.

If you can find a pure PHP implementation, you can make that work by installing it wherever you want (~/lib/php is a standard location) and adding that directory to PHP's include path by calling get_include_path/set_include_path in an initialization script (which you'd include on all entry scripts).

PHP also has a number of standard web service extensions (some are listed among the other extensions) that you can use, though off the top of my head I'm not sure which extensions are loaded.
 
Last edited:

kloadx10

New Member
Messages
24
Reaction score
0
Points
0
If you are trying to do some authorization of some sort then i would suggest you use cUrl as many of the web hosts allow that support and its really easy to implement.
 

nbkx10mx

New Member
Messages
8
Reaction score
0
Points
0
Allright, looks like I got SOAP webservice working.

Thanks, guys. Your help is much appreciated!
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Another option (and my personal preference) would be to implement a RESTful web service. Rather than layering another protocol on top of HTTP (such as SOAP or XML-RPC), REST uses HTTP for transport and any format you want for data interchange (typically some combination HTML, JSON and XML), which constitute different representations of a named resource. Since every browser supports the technologies involved, it's easy to debug and for third parties to use. Also, REST APIs are discoverable, so you don't need to publish anything other than an entry point. The combination of basic web technologies and discoverability means REST APIs require less studying in order that others can use them, unlike other APIs which require more documentation.

See also Why REST?.
 

nbkx10mx

New Member
Messages
8
Reaction score
0
Points
0
While we're on it, now trying to access that service from client side with java script. I have the URL of the service and the URL of WSDL, now I just need to know how to configure XMLHttpRequest correctly and how to pass all the parameters and get the result from the server. Specifically, can't figure out where WSDL comes into the play.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
You can use a tool to automatically generate JS (or code in other languages) that accesses the service. A search for "WSDL Javascript" turns up a number of potentially useful pages (the last three won't be of use on X10):

 

nbkx10mx

New Member
Messages
8
Reaction score
0
Points
0
Got it working with JSON eventually, so much easier and simple than SOAP.
Thanks for all your help guys, really appreciated.
 
Top