Showing posts with label HowTo. Show all posts
Showing posts with label HowTo. Show all posts

Saturday, March 24, 2012

PHP SOAP client to consume JAX-WS

For couple of days I was googling and researching for a descent solution to my problem to access and consume the services exposed over a JAX-WS from my php application. Actually, I have to write a client so that I can save data from my php application (A subscriber application info management system for the telco company I am working for) to IN database where I have to do so over a JAX-WS interface.
Usually, I woud've followed my previous post. But it din work in this case- the problem and a basic setup is I got from the following location:
http://www.lampjunkie.com/2010/03/get-phps-soapclient-to-speak-with-javas-jax-ws/
But that either din resolve my problem entirely; as my JAX-WS needs a BASIC HTTP AUTHENTICATION to access it. So, following was my solution :

Note:
From php manual I must quote that you must set uri and location directives while invoking webservice with wsdl.I mean when you create the SoapClient object.

Now, that is how I retrieved data from the web service. Next, I will try to save the data and will share how I do it.

Reference:
  1. php manual for soap client. A must read with care of the all the options.
  2. soapUI. A must have tool while working with soap - to easy analyze things.
  3. wsf/php. A framework for php to easily play with enterprise level web services. I will write my experience with it some other time.

Sunday, November 13, 2011

Installing php driver for MongoDB

PHP      &   mongoDB


This is the post where I will configure php to work with mongoDB. On my previous post I have put the teps I followed to install mongoDB on my Ubuntu [TurnKey Linux] running on VirtualBox.
1.Run:
sudo pecl install mongo
2.Open your php.ini file and add to it:
extension=mongo.so
It is recommended to add this to the section with the other "extensions", but it will work from anywhere within the php.ini file.
3.Restart your web server (Apache, nginx, etc.) for the change to take effect.
Note:
pecl requires that pear be installed. For those using apt-get, you may need to run the following:
sudo apt-get install php5-dev php5-cli php-pear
However, you can download the source for the driver and can compile it manually :
shell> tar -xzvf mongo-1.2.6.tar.gz
shell> cd mongo-1.2.6
shell> phpize
shell> ./configure
shell> make
shell> make install
Check with the phpinfo

Starting MongoDB and php on Ubuntu

Installing MongoDB on Ubuntu:
1. Add 10gen package to source.list 
The 10gen package contains the latest mongoDB version, append below line to the end of the file “/etc/apt/sources.list
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen
For example, you can vim the “source.list” and append the 10gen package like this :
$ sudo vim /etc/apt/sources.list
File : /etc/apt/sources.list
#...content omitted ...
## This software is not part of Ubuntu, but is offered by third-party
## developers who want to ship their latest software.
deb http://extras.ubuntu.com/ubuntu natty main
deb-src http://extras.ubuntu.com/ubuntu natty main
 #mongo repo ##########
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen

 2. Update package
Update the modified “/etc/apt/sources.list” :
sudo apt-get update
Now, a new “mongodb-10gen – An object/document-oriented database” is available for install.
  3. Add GPG Key
10gen package required GPG key, import it :
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
   4. Install mongodb-10gen
Everything is ready, now you can Install the mongoDB package :
sudo apt-get install mongodb-10gen
    5. Post-InstallationVerification
Now, mongoDB is installed, started, and auto start mongoDB script is generated to “/etc/init/mongo” and “/etc/init.d/mongo“. In addition, all mongoDB files are copied to “/usr/bin” folder.

The main configuration file “mongodb.conf” is located at “/etc/mongodb.conf“, change the values to customize your mongoDB server.

File : mongodb.conf
# mongodb.conf
# Where to store the data.
# Note: if you run mongodb as a non-root user (recommended) you may
# need to create and set permissions for this directory manually,
# e.g., if the parent directory isn't mutable by the mongodb user.
dbpath=/var/lib/mongodb
#where to log
logpath=/var/log/mongodb/mongodb.log logappend=true
#port = 27017
#......
   6. Verification
To verify it, just connect it with “mongo”
$ mongo
MongoDB shell version: 1.8.1 connecting to: test
>
on my next post I will try to connect php with this mongoDB.