Help with System.NullReferenceException: Object reference no

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jabba
Forum Newbie
Posts: 4
Joined: Sat Sep 15, 2007 7:01 pm

Help with System.NullReferenceException: Object reference no

Post by Jabba »

I was wondering if someone might have a look at the code I've written to call a commercial web service and point me in the correct direction.

I'm new to php and webservices. My background is mostly Unix and C.

Some questions I have are as follows:

1) The last three parameters to the Webservice are parameters that the Webservice returns. I'm not sure if I need to pass these in. I've commented them out and still get the same error.

2) The baData field is expected to be a data type of s:base64Binary. I'm not sure how to code that. I've made it a string as the data I need to pass it is a string (i.e., "P2*01*28").

Here is the call I am trying to make to the Webservice

Code: Select all

.
.
$NumerexBase = "http://www.nmrx.com/CWB/DCWS/" ;
$SendMessageToUnit = $NumerexBase . "SendMessageToUnit" ;

// XML Variables
$iProviderID = 1004 ;
$sUnitID = "1010068916" ;
$iEncoding = 8 ;
$baData = "P2*01*28" ;
$iDataLen = 8 ;
$iTransID = 0 ;
$iErrorCode = 0 ;
$sErrorMsg  = "" ;

// Establishing the client
$client = new soapclient('https://prodgw.cellemetry.com/CWB/DCWS.asmx?wsdl', true);

// Setting credential username and password
$client->setCredentials($strUserID, $strPassword, "basic");

//Lets wrap parameters for the call
$param = array(
		'iProviderID' => $iProviderID,
		'sUnitID' => $sUnitID,
		'iEncoding' => $iEncoding,
		'baData' => $PulseCount,
		'iDataLen' => strlen($PulseCount,
		'iTransID' => $iTransID,
		'iErrorCode' => $iErrorCode,
		'sErrorMsg' => $sErrorMsg
);

//Make a call
$result = $client->call('SendMessageToUnit', array('parameters' => $param), '', $SendMessageToUnit, false, true);
Here is what the Webservice is expecting

Code: Select all


  <?xml version="1.0" encoding="utf-8" ?> 
- <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://www.nmrx.com/CWB/DCWS/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://www.nmrx.com/CWB/DCWS/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:types>
- <s:schema elementFormDefault="qualified" targetNamespace="http://www.nmrx.com/CWB/DCWS/">
- <s:element name="SendMessageToUnit">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="1" maxOccurs="1" name="iAccountID" type="s:int" /> 
  <s:element minOccurs="0" maxOccurs="1" name="sUnitID" type="s:string" /> 
  <s:element minOccurs="1" maxOccurs="1" name="iEncoding" type="s:int" /> 
  <s:element minOccurs="0" maxOccurs="1" name="baData" type="s:base64Binary" /> 
  <s:element minOccurs="1" maxOccurs="1" name="iDataLen" type="s:int" /> 
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:element name="SendMessageToUnitResponse">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="1" maxOccurs="1" name="SendMessageToUnitResult" type="s:boolean" /> 
  <s:element minOccurs="1" maxOccurs="1" name="iTransId" type="s:int" /> 
  <s:element minOccurs="1" maxOccurs="1" name="iErrorCode" type="s:int" /> 
  <s:element minOccurs="0" maxOccurs="1" name="sErrorMsg" type="s:string" /> 
  </s:sequence>
  </s:complexType>
  </s:element>

Here is the error:

Code: Select all


Fault
Array
(
    [faultcode] => soap:Server
    [faultstring] => System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at DCWS.SendMessageToUnit(Int32 iAccountID, String sUnitID, Int32 iEncoding, Byte[] baData, Int32 iDataLen, Int32& iTransId, Int32& iErrorCode, String& sErrorMsg)
   --- End of inner exception stack trace ---
    [detail] => 
)

Request
POST /CWB/DCWS.asmx?wsdl HTTP/1.0
Host: prodgw.cellemetry.com
User-Agent: NuSOAP/0.7.2 (1.94)
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: "http://www.nmrx.com/CWB/DCWS/SendMessageToUnit"
Authorization: Basic c2F2b25ldHRlOlNhdjBuMzExMw==
Content-Length: 824

<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><SendMessageToUnit><parameters><iProviderID xsi:type="xsd:int">1004</iProviderID><sUnitID xsi:type="xsd:string">1010068916</sUnitID><iEncoding xsi:type="xsd:int">8</iEncoding><baData xsi:type="xsd:string">P2*01*28</baData><iDataLen xsi:type="xsd:int">8</iDataLen><iTransID xsi:type="xsd:int">0</iTransID><iErrorCode xsi:type="xsd:int">0</iErrorCode><sErrorMsg xsi:type="xsd:string"></sErrorMsg></parameters></SendMessageToUnit></SOAP-ENV:Body></SOAP-ENV:Envelope>
Response
HTTP/1.1 500 Internal Server Error
Date: Fri, 28 Sep 2007 13:46:51 GMT
Server: Microsoft-IIS/6.0
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Content-Length: 743

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body><soap:Fault><faultcode>soap:Server</faultcode> <faultstring>System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at DCWS.SendMessageToUnit(Int32 iAccountID, String sUnitID, Int32 iEncoding, Byte[] baData, Int32 iDataLen, Int32& iTransId, Int32& iErrorCode, String& sErrorMsg)
   --- End of inner exception stack trace ---</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>


I've been able to call other Webservices with no problems, although they were not https calls. Could this be the problem?

Any help would be appreciated.
jeffery
Forum Contributor
Posts: 105
Joined: Mon Apr 03, 2006 3:13 am
Location: Melbourne, Australia
Contact:

Post by jeffery »

how about testing it without https to eleminate that doubt.
jeffery
Forum Contributor
Posts: 105
Joined: Mon Apr 03, 2006 3:13 am
Location: Melbourne, Australia
Contact:

Post by jeffery »

Post Reply