i new world of php , coding have helped me answer number of questions have posted know. have opportunity jump deep end seeing have no clue php , web services, seeking help. appreciate if point me in right direction have not been able find examples nor detailed information regarding it.
effectively there php page needs pass values .net web service i.e. name, email, mobile number , upon receipt of such information web service sends out text message. information have far
the allocation service uses basic http binding , transportwithmessagecredential security.
sample c# code using reference generated visual studio tooling allocation.allocationservicev3client client = new allocation.allocationservicev3client(); allocation.allocateresult result; string vouchercode; datetime expirydate; string displaymessagetext; client.clientcredentials.username.username = ? ; client.clientcredentials.username.password = ? ; result = client.allocatetoconsumermobileandsendsms(out vouchercode, out expirydate, out displaymessagetext, clientid, clientreference, campaignid, activityid, mobilenumber); if (result != allocation.allocateresult.success) { }
i have no clue php , web services
first things first, pick brain out of c# soup , sit out dry off few hours. php simple language simple things. if you're new it, don't want try , make complex things, , don't want try writing c# style code in php.
let's take "web services" example of "complex" thing. in circles, means horribly designed monstrosities soap. vs makes relatively easy build soap bindings existing classes, it's not painful solution you.
soap very painful solution php.
effectively there php page needs pass values .net web service
it sounds have existing web service set then, correct?
you could try , use built in soap client, it's undebuggable , unconfigurable binary blob of horrors make want kill if doesn't work immediately.
edit: section below written incorrectly assuming both sides under control. not case, can disregard rest of answer. i'm leaving because may valuable others.
i advise different approach. set endpoint (url) in .net application expects data you've specified post values, , have php post data. has distinct advantage of being incredibly simple. because you're new php, simple big win.
(in other words, ditch "web service" -- or make parallel copy if other things consume service already.)
php comes service called pear, repository of helpful classes. can use http_request2 build http post request. chances it's installed. if isn't, it's easy install either @ system level using pear
command, or locally in project.
here's quick example code copied straight out of reference guide:
$request = new http_request2('http://www.example.com/your/endpoint/url.foo'); $request->setmethod(http_request2::method_post) ->addpostparameter('name', '...') ->addpostparameter('email', '...') ->addpostparameter('mobile', '...'); $response = $request->send();
you can read response needed.
now, isn't perfect solution. c# code mentions username , password, suppose could included in post data. use http authentication (supported http_request2) instead.
Comments
Post a Comment