Re: consuming WCF with php5.2.6

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yoni,

I fiddleded with the code and from the errors, and this is definitely the
proper way to format the message:

<?php
error_reporting(E_ALL);

echo 'hello';

$client = new SoapClient('
http://services.ciphe.org.uk/FindPlumber/FindPlumberService.svc?wsdl',
Array(
'trace' => true,
'soap_version' => SOAP_1_1,
'connection_timeout' => 5,
'proxy_host' => localhost,
'proxy_port' => 8888
)
);

print_r($client);

$params = Array('requestMessage'=> Array(
'MaxResults'=> 10,
'Password '=> 'mypasswordgoeshere',
'PostCode'=> 'BS24 0HT',
'Radius'=> 25,
'Username '=> ',username'
));

$result = $client->PerformSearch($params);

$print_r($result);

?>


If you do that you get a soap fault, but that is happening at the
application level, so you need to set some different parameters. However,
the basic "array within an array" of the soap request is properly setup. You
can tell this is true by mispelling "requestMessage". Instead of the http
500 response and the soap fault you get "RequestMessage cannot be null"

Regards,

Justin Dearing


On Sun, Aug 7, 2011 at 4:08 AM, yonialhadeff <yonia@elyotech.com> wrote:

>
> Hello,
>
> Did you find a solution to send parameter through WCF service ?
>
> I would like to know how you did that.
>
> Thanks a lot
>
> Yoni
>
> Derek Almond wrote:
> >
> > I'm having trouble finding the magic combination to consume a WCF
> > service, can anyone advise on where I'm wrong?
> >
> > I've got a test script as follows, (it's locked down to my IP so i
> > dont think you;'ll be able to test it, but i've included the wsdl
> > location for completeness)
> >
> > any help really appreciated.
> >
> > D
> >
> > <?php
> >
> > try{
> >     $client = new
> > SoapClient("
> http://services.ciphe.org.uk/FindPlumber/FindPlumberService.svc?wsdl";);
> >     # get a list of the available methods
> >     print "Functions:\n";
> >     var_dump($client->__getFunctions());
> >
> > /* this outputs
> >
> >
> > Functions:
> > array(1) {
> >   [0]=>
> >   string(62) "PerformSearchResponse PerformSearch(PerformSearch
> > $parameters)"
> > }
> >
> > */
> >
> >
> >
> >     print "\n\n";
> >     print "Types:\n";
> >     var_dump($client->__getTypes());
> >     print "\n\n";
> >
> > /* this outputs
> >
> >
> > Types:
> > array(11) {
> >   [0]=>
> >   string(40) "struct ArrayOfResult {
> >  Result Result;
> > }"
> >   [1]=>
> >   string(344) "struct Result {
> >  string Address1;
> >  string Address2;
> >  string Address3;
> >  string CompanyName;
> >  string Contact;
> >  string Country;
> >  string County;
> >  string Email;
> >  string Fax;
> >  string FullAddress;
> >  GMapPoint MapPoint;
> >  string Mobile;
> >  string Postcode;
> >  boolean Registered;
> >  string Telephone;
> >  string Town;
> >  string WebAddress;
> >  string WorkCategories;
> > }"
> >   [2]=>
> >   string(120) "struct GMapPoint {
> >  string Address;
> >  int ID;
> >  string IconImage;
> >  string InfoHTML;
> >  double Latitude;
> >  double Longitude;
> > }"
> >   [3]=>
> >   string(8) "int char"
> >   [4]=>
> >   string(17) "duration duration"
> >   [5]=>
> >   string(11) "string guid"
> >   [6]=>
> >   string(21) "string ResponseStatus"
> >   [7]=>
> >   string(109) "struct RequestMessage {
> >  int MaxResults;
> >  string Password;
> >  string PostCode;
> >  int Radius;
> >  string Username;
> > }"
> >   [8]=>
> >   string(92) "struct ResponseMessage {
> >  string Messsage;
> >  ArrayOfResult Results;
> >  ResponseStatus Status;
> > }"
> >   [9]=>
> >   string(56) "struct PerformSearch {
> >  RequestMessage requestMessage;
> > }"
> >   [10]=>
> >   string(70) "struct PerformSearchResponse {
> >  ResponseMessage PerformSearchResult;
> > }"
> > }
> >
> > */
> >
> > /* based on the above, i think i need an array of paramaters, and that
> > array is named RequestMessage
> >
> >
> >     $myParam=array("RequestMessage"=>array(
> >         'MaxResults'=> 10,
> >         'Password '=> 'mypasswordgoeshere',
> >         'PostCode'=> 'BS24 0HT',
> >         'Radius'=> 25,
> >         'Username '=> ',username'
> >          ));
> >
> >
> >     #$result = $client->__soapCall('PerformSearch',array('RequestMessage'
> > =>$myParam));
> >
> >     I believe that either the line above or the three lines below should
> > work
> >
> >     $wcf = $client->PerformSearch($myParam);
> >     #$wcfResult = $wcf->ResponseMessage;
> >     #print  $wsResult;
> >
> >
> > } catch (Exception $e) {
> >     print  'Caught exception: '.  $e->getMessage(). "\n";
> >
> >
> > /* an exception is thrown :
> >
> > Caught exception: Object reference not set to an instance of an object.
> >
> > */
> >
> >
> > }
> >
> > --
> > PHP Soap Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/consuming-WCF-with-php5.2.6-tp25653915p32211304.html
> Sent from the Php - Soap mailing list archive at Nabble.com.
>
>
> --
> PHP Soap Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

[Index of Archives]     [PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux