Page 1 of 1

How to Call Asp.net webservices from PHP

Posted: Wed Jun 04, 2008 7:56 am
by sharma_gaurav
Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  Posting Code in the Forums to learn how to do it too.[/color]


Hi all,

I am calling a asp.net c# web service using php5 soap client , the first argument of the calling function is an array and the second object is string my code snippest is below

Code: Select all

if ($this->IsValid)  // check if input validation is successful
        {
            $amount = TPropertyValue::ensureString($this->Amount->Text);
        $cardtype = $this->CardType->SelectedValue;
        $cardcard_number = TPropertyValue::ensureString($this->CardNumber->Text);
        $securityCode = TPropertyValue::ensureString($this->SecurityCode->Text);
        $ExpMonth = $this->Month->SelectedValue;
        $ExpYear = $this->Year->SelectedValue;
        $fname = TPropertyValue::ensureString($this->FirstName->Text);
        $lname = TPropertyValue::ensureString($this->LastName->Text);
        $address1 = TPropertyValue::ensureString($this->Address1->Text);
        $address2 = TPropertyValue::ensureString($this->Address2->Text);
        $city = TPropertyValue::ensureString($this->City->Text);
        $state = TPropertyValue::ensureString($this->State->Text);
        $zip = TPropertyValue::ensureString($this->Zip->Text);
        
        /*$Data = array('BuyerAddress1' => $address1,'BuyerAddress2' => $address2,'BuyerCity' => $city , 'Country' => 'US','BuyerZipCode' => $zip,'BuyerState' => $state,'BuyerFirstName' => $fname, 'BuyerLastName' => $lname,'CreditCardNumber' => $cardcard_number,'CreditCardType' => $cardtype , 'CVV2' => $securityCode,'ExpMonth' => '02' ,'ExpYear' => '2018','Paymentcurrency'=>'USD','PaymentAmount' => $amount,'PaymentActionType' => 'Sale');*/
        
        $param->BuyerAddress1 = $address1;
        $param->BuyerAddress2 = $address2;
        $param->BuyerCity = $city;
        $param->Country = "US";
        $param->BuyerZipCode = $zip;
        $param->BuyerState = $state;
        $param->BuyerFirstName = $fname;
        $param->BuyerLastName = $lname;
        $param->CreditCardNumber = $cardcard_number;
        $param->CreditCardType = $cardtype;
        $param->CVV2 = $securityCode;
        $param->ExpMonth = "02";
        $param->ExpYear = "2018";
        $param->Paymentcurrency = "USD";
        $param->PaymentAmount = $amount;
        $param->BuyerIPAddress = "127.0.0.1";
        $param->PaymentActionType = "Sale";
        //var_dump($objPaymentReq);*/
        
        //$obj->objPaymentReq = $Data;
        //print '<pre>';print_r($objPaymentReq);print '</pre>';exit;
        try
        {
           $client = new SoapClient('http://203.197.202.163/SprasiaPaypalService/PaymentService.asmx?wsdl');
           $PaymentGateway = "PayPal";
           $result = $client->DoPayment(array('PaymentRequest' => $param) , $PaymentGateway);
            
            if($client->fault)
            {
            print "There is some fault";
            
            //echo json_encode($result);
            //print "This is Transaction Key".$result->TransactionID;
            }
            else{
            print_r($result);
            }
         }
         catch(Exception $e)
         {
            print $e->getMessage();
         }
        }
And the webservice also returns the array of values with key value pair.

But when i try to print the "$result" using print_r is give only stdClass Object ( )

Please sugget for the same what i am doing wrong.


Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  Posting Code in the Forums to learn how to do it too.[/color]

Re: How to Call Asp.net webservices from PHP

Posted: Wed Jun 04, 2008 2:48 pm
by RobertGonzalez
What format is the return?

Re: How to Call Asp.net webservices from PHP

Posted: Wed Jun 04, 2008 10:34 pm
by sharma_gaurav
Everah wrote:What format is the return?
Hi,

Thnx for the concern
The Web service also returns the object/array of values like transactionid , amount.

Please reply as soon as possible.

Re: How to Call Asp.net webservices from PHP

Posted: Thu Jun 05, 2008 10:24 am
by RobertGonzalez
What I am asking is what type of return is coming back. Is it XML? Is it a textual response? All you are doing is consuming a service, so the processing of the request is generally handled at the web service providers end and a data set of some sort is returned to you.