Jump to content

Calling a .NET webservice from PHP (Wordpress)


MarkusJ

Recommended Posts

Hi, I have spent the last few hours trying to consume a .NET webservice (.asmx) from a php page. I have tried all sorts of recommendations but I am still getting the following error

SoapClient->__call('LogUser', Array) #1 /home/mywebsite/public_html/sitefun.com/wp-content/themes/supermodne/functions.php(18): SoapClient->LogUser(Object(stdClass))

The actual .NET webservice that I am trying to call is an extremely simple .asmx webservice (not WCF) and the method is very simple (interface is below)

 [WebMethod] 
        public string LogUser(string IPAddress, string Key, string ID, string Referrer)
        {   

This is the code that I am using to call the webservice in php

$client = new SoapClient('http://services.mywebsite.net/webservices/visitorlog.asmx?WSDL');
        
        $requestvar = $_SERVER['REMOTE_ADDR'];
        $requestKey = 'guid';
        $requestID = '6'
        $referrer = $_SERVER['HTTP_REFERER'];
        
        if (!empty($_SERVER['HTTP_REFERER']))
        {
            $parameters = array('IPAddress'=>$requestvar,'Key'=>$requestKey,'ID'=>$requestID,'Referrer'=>$referrer);
                
                 $result = $client->LogUser($parameters); // This is the line that is causing the error

I must be doing something silly as I am new to php / services so I would appreciate any help

 

Best wishes and thanks in advance

Mark


                  

Link to comment
Share on other sites

LOL, sorry; you are correct (wood for the trees!) I am getting an "Object not set to an instance of an object" error when I call the line

$result = $client->LogUser($parameters); // This is the line that is causing the error

Thanks again

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.