Google Groups Home
Help | Sign in
php
PHP SOAP with .NET service "Object reference not set to an instance of an object"
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Vlad  
View profile
 More options May 2, 3:32 pm
From: Vlad <wimpo...@gmail.com>
Date: Fri, 2 May 2008 12:32:55 -0700 (PDT)
Local: Fri, May 2 2008 3:32 pm
Subject: PHP SOAP with .NET service "Object reference not set to an instance of an object"
Hello,
HELP!!!

I am using PHP built-in SOAP Extension.

I get "Object reference not set to an instance of an object" SoapFault
exception when passing an object (a PHP class) to a .NET webservice
from a PHP soapclient. When I retrieve data from the service I get no
errors.

In fact, the object does not even appear in the SOAP envelope, ONLY
it's fields appear.
Has anybody had this problem?

Here is how I do it:
--------------------------------------------------------------------------- ------------------------------------------------------
class SpParent {
 public $ParentID;
 public $ParentType;

}

$params = null;
settype($params, 'object'); # this may not even be needed

# Create new instance of class and assign the values
$params = new SpParent;
$params->ParentID = 10;
$params->ParentType = 'primary';

### Create new instance of SOAP client
# NOTE: map 'Parent' to 'SpParent', because the class is called
'Parent' on the server,
# and PHP does not allow to create a class called 'Parent' (reserved
word)
$client = new SoapClient('http://path/to/some/wsdl', array( 'classmap'
=> array ("Parent" => "SpParent"),

'trace' => true,

'exceptions' => true);

### Call function 'AddParent' and pass the object
$AddParentResponse = $client->__soapCall('AddParent', array($params));

--------------------------------------------------------------------------- ------------------------------------------------------
HERE IS HOW THE SOAP ENVELOPE LOOKS LIKE:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/
envelope/"
                                  xmlns:ns1="http://path/to/some/
namespace">
    <SOAP-ENV:Body>
        <ns1:AddParent>
            <ns1:ParentID>10</ns1:ParentID>
            <ns1:ParentType>primary</ns1:ParentType>
        </ns1:AddParent>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Now according to the webservice sample request the ParentID and
ParentType elements should be enclosed within a 'Parent' element.
--------------------------------------------------------------------------- ------------------------------------------------------
HERE IS HOW THE SOAP ENVELOPE SHOULD LOOK LIKE:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/
envelope/"
                                  xmlns:ns1="http://path/to/some/
namespace">
    <SOAP-ENV:Body>
        <ns1:AddParent>
            <ns1:Parent>
                <ns1:ParentID>10</ns1:ParentID>
                <ns1:ParentType>primary</ns1:ParentType>
            </ns1:Parent>
        </ns1:AddParent>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
--------------------------------------------------------------------------- ------------------------------------------------------
I used nusoap, PEAR SOAP, but these are no good as well, if not worse.
I would greatly appreciate any help! This is driving me nuts already.

-vlad


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google