3

I understand that this "Object reference not set to an instance of an object" has come up a lot but all of the answers I've looked at don't seem to be helping me out.

Here's my WSDL : https://app.20-20insights.com/testepos/servicetrx.svc?wsdl

I'm trying to call the the BeginTrx() function but I'm getting an error.

Any advice or help is much appreciated.

Thanks, Martin.

setting the TrxIdentifier object

$trxIdentifier = new TrxIdentifier; $trxIdentifier->ClientId = 9372490002639296; $trxIdentifier->DeviceId = "123"; $trxIdentifier->OpId = "123"; $trxIdentifier->PosDescription = "123"; $trxIdentifier->PosId = "123"; $trxIdentifier->PosTxnId = "123"; $trxIdentifier->SiteId = "12312"; $trxIdentifier->Token = "3"; $trxIdentifier->TrxdateTime = new DateTime; 

Performing the call...

$client = new SoapClient($wsdl, array('trace'=>true, 'exceptions'=>true, 'classmap'=>array('TrxIdentifier'=>"TrxIdentifier", 'MemberInfo'=>"MemberInfo", 'Response'=>"Response", 'MemberDetail'=>"MemberDetail"))); $response = $client->BeginTrx($trxIdentifier ); 

Error :

Object reference not set to an instance of an object. a:InternalServiceFaultObject reference not set to an instance of an object.Object reference not set to an instance of an object. at CatalystSpsTrx.Contracts.Service.ServiceTrx.BeginTrx(MemberInfo& mem, TrxIdentifier conTrx) in C:\Projects\2010\CatTrxServices\CatalystSpsTrx.Contracts\Service\ServiceTrx.cs:line 38 at _dynamic_CatalystSpsTrx.Contracts.Service.ServiceTrx.BeginTrx(Object , Object[] ) at Spring.Reflection.Dynamic.SafeMethod.Invoke(Object target, Object[] arguments) at Spring.Aop.Framework.DynamicMethodInvocation.InvokeJoinpoint() at Spring.Aop.Framework.Adapter.AfterReturningAdviceInterceptor.Invoke(IMethodInvocation invocation) at Spring.Aop.Framework.Adapter.ThrowsAdviceInterceptor.Invoke(IMethodInvocation invocation) at CompositionAopProxy_d0e73463863e4ccd9c2db0a96530bd0d.BeginTrx(MemberInfo& mem, TrxIdentifier conTrx) at ServiceTrx.BeginTrx(MemberInfo& mem, TrxIdentifier conTrx) at SyncInvokeBeginTrx(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)System.NullReferenceException 
2
  • That error is generated by the server, not PHP. You will have to look at the server code or notify the API administrator of the service you are using. Commented May 29, 2012 at 21:52
  • Thanks, I've sent them an email and I'm currently waiting to hear back from them. Commented May 30, 2012 at 8:37

1 Answer 1

3

That error occurs because your input structure is wrong. Your WSDL states that it has to be called in this way:

$response = $client->BeginTrx(array('trx' => $trxIdentifier)); 

Take a look at the WSDL, here is the root input definition for service BeginTrx:

<wsdl:message name="IServiceTrx_BeginTrx_InputMessage"> <wsdl:part name="parameters" element="tns:BeginTrx"/> </wsdl:message> 

As you can see, the input is of type BeginTrx. If you follow the WSDL, you'll find that is defined as:

<xs:element name="BeginTrx"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="trx" nillable="true" type="tns:TrxIdentifier"/> </xs:sequence> </xs:complexType> </xs:element> 

So there you can see that BeginTrx has a param name of trx and a value of type TrxIdentifier.

Following the WSDL again, TrxIdentifier is defined as:

<xs:complexType name="TrxIdentifier"> <xs:sequence> <xs:element minOccurs="0" name="ClientId" type="xs:int"/> <xs:element minOccurs="0" name="DeviceId" nillable="true" type="xs:string"/> ................. </xs:sequence> </xs:complexType> 
Sign up to request clarification or add additional context in comments.

4 Comments

Hi, that's excellent. It accepted my request. It did give me another error which I'll have to look into: The value '9372490002639296' cannot be parsed as the type 'Int32' pardon my ignorance too though, where do you see in the WSDL that it has to be passed in using 'trx'?
ClientId is a 32 bit integer, you're passing a number which far exceeds the maximum of 2147483647. If you need to pass that number, the service provider will have to change the data type to a string to avoid the 32bit limit. I explained where trx comes from, look at my second WSDL snippet.
You are a hero my good man! Thanks very much for you help. This is much appreciated. Best explaination of this error I've seen.
Glad to have helped. This error is almost always due to a wrong input structure when calling .NET web services.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.