Create a webservice in Php native - php

I am new in web service. I was totally confused when seeing examples to create web service in internet. Actually, My client have xml to place the orders. what they want is they need to create a wsdl(web service) to call the xml by their vendor forms. So i need to create a webservice that integrate with xml and vendopform(it may be in any language). How i can do this, my mind has empty now to think this. Can any body help me to sort this issue.

If you're creating a SOAP service (which it sounds like you are, and I feel sorry for you ;)), try starting by looking at PHP's SOAP extension:
http://php.net/manual/en/book.soap.php
If you can create something more RESTful, Ruby on Rails does a good job at allowing you to throw together a quick and dirty web service without too many headaches, but even in PHP you can create RESTful APIs pretty easily.
You can read the HTTP request body via e.g. fgets(STDIN) if your requests will accept XML as a POST/PUT format.
But yes, your question is too broad to provide anything more than nudges towards the tools you might choose to use.

Related

PHP SOAP OTA Connection

for a customer I want to implement the OTA service in an interface to check availabilty and things like that.
I've downloaded the 2017 specifications from OpenTravel. But I lack some information. I want to realize it with PHP and SOAP and later connect it to Magento. But I can't find any url for the SOAP client to send those XMLs to.
I would greatly appreciate any help on this topic or maybe suggestions to do it in an easier way.
Greetings
Consuming OTA SOAP web services is tricky as PHP SoapClient class does not handle it properly.
First you should generate the PHP sdk from the WSDL corresponding to the availabilities you need to send requests to. You should give the PackageGenerator project from Github a try.
Nevertheless, as I said, the native PHP SoapClient class does not map the parameters to the XML request correctly. This is where you have to write your proper code to handle the mapping from the PHP objects to the XML request.
As I work regularly on these sorte of issues, I can help you further but only privately at contact#wsdltophp.com.

Proper RESTful SOA approach in PHP applications?

So, i've been reading a lot on SOA's lately and been trying to implement something useful. I have started with a simple blog, creating the RESTful API. So far, so good. It works perfectly. However, i'm starting to pull my hair off when writing the web interface that will consume the RESTful API. I don't know if i'm doing the right thing.
For example, the web interface has an admin panel. That admin panel makes HTTP requests to the API, through file_get_contents and stream options. Right now, the API is localhost, as well the web interface, but the whole process is a little slower. Is this right? Is this the proper way of implementing a SOA? Also, i'm dealing with little bits of duplicated code for validation. Where should i validate data? In the API or the web interface? What is the best approach?
Tips, tutorials and, specially, books are welcome. This is being implemented using Silex, built on top of Symfony components.
That's exactly how i do it. Although the connection with localhost might seem an overhead at first, it is a feature, since you're ready to deploy your web interface application anywhere and still consume your API, that might be anywhere. Of course, you would put some SSL over this.
As for Validation, you should validate on the API and return HTTP status codes for those situations (for example, "400 Bad Request" for invalid parameters). This way, any other client can interpret the response from the API and treat that to display how they want. In the case of your web interface, nice little error messages based on the HTTP status code.
What other problems are you facing? Also, as far as general SOA architecture is concerned, this book is very good.

Creating a fairly primitive Web Service

We are rolling out one of our services to another service provider in PHP. They have already built the client, it just sends data in a post (no xml/json etc). Our script then processes it and returns an xml string with the response. Also they will need a token authentication system. Because of the fact they are just using cURL to post raw data, I don't think I can use soap/rest/xml-rpc ... can anyone point me to any good tuts etc?
Cheers,
Oauth is a secure and easy to implement for security solution for tokens. And they have libraires for java, php, python, and pretty much any language you can think of.
Very strange (and backwards) they built a client without an existing service. but the important thing is to document the interface between your two systems, and adhere to it.
David Walsh explains a simple php web service that returns JSOn or XML.
http://davidwalsh.name/web-service-php-mysql-xml-json

Android and http communications

I have looked on here and anddev for a suitable response, but haven't found anything suitable.
Here is the question: My friend has an instant chat application with iPhone, and since I have some basic android experience he asked me to check out "porting" it to Android. So before I set up the UI, I decided to look into php which I don't have much experience with. I know the UI will need an array to call contacts, but I'm not sure about retrieving the information from the php.
How do I know if I can use his script or not? I haven't found any good tutorials about Android and Php - has anyone found one?
I might as well learn this stuff now because my next app will require an online database to be used in it - I know his has users and passwords, and he'd like to be able to send im's between iPhone and Android clients.
Thanks for any help you may provide!
EDIT:
Yes, this issue is more related to http requests from android to a remote server; I have changed the tags and subject accordingly, but would still appreciate a guide to android-friendly php writing. Thank you!
There really isn't Android-Friendly PHP but there is mobile friendly PHP. Basically, you need your PHP scripts to emit something that is easy to parse in an application (like XML or JSON) rather than the standard HTML. After that, all you need to do is figure out what the API should look like on the server side. That is, what functions does the server need to provide and how is it going to provide them. Are you going to use simple HTTP authentication or are you going to use something more complicated?
With regards to his chat application, I would imagine that if he already has an iPhone version, then you won't need to mess with the sever side at all. All you need to do is figure out what URLs and parameters to use for what operations. You also need to ask him what data format his server uses. If it's XML, you need to find an XML parser, if it's JSON then you need to find a JSON parser etc. (there are plenty of tutorials on how to do both in Android via Google). I would start by asking him, at a high-level, not with Objective-C specifics, how his chat application communicates with the sever. You can then use that to build your application to communicate in the same manner.

how to consume .net webservices

please tell that can we consume .net web services in php or not.
if yes then please tell me how can we do it.
i am to create a web service which takes values and save it in database also it will take values and reply some data as a standard xml format.
i know how to create web service and how to use it in asp.net but don't know how to use/call it from php.
thing is that i will not be writing code in php to consume but wants to know that do i need to take care of any special thing or need to do some extra code to make it available and use by php developers.
i am to create web service in .net framework 2.0
Thanks
It's possible, but it looks like you have your work cut out for you. .Net web services are based on SOAP. The PHP class you're looking for is SoapClient.
Take some time to read through the PHP site's documentation. .Net hides a lot of the raw SOAP nuts and bolts, so you're going to need to peel back the curtain on your web service a bit.
One easy way is to play with an existing WS client through a proxy like Fiddler, which lets you see exactly what's going back and forth.
Good luck,
n.

Categories