I want to send a custom object thats defined as a datacontract in my .NET web service from PHP. I'm attempting to accomplish this via SOAP. Here is my datacontract.
[DataContract(Namespace = "www.xxxxx.com/data/v1")]
public class CreditCardSubmission
{
[DataMember]
public string CreditCardNumber { get; set; }
[DataMember]
public int ExpireMonth { get; set; }
[DataMember]
public int ExpireYear { get; set; }
[DataMember]
public string CardNickname { get; set; }
[DataMember]
public string CardholderName { get; set; }
[DataMember]
public string Address { get; set; }
[DataMember]
public string City { get; set; }
[DataMember]
public string State { get; set; }
[DataMember]
public string PostalCode { get; set; }
[DataMember]
public string Country { get; set; }
}
Here is the function
string SubmitCreditCardInformation(string applicationSessionId,
CreditCardSubmission request)
Here is my PHP code.
$result2 = $client->call("UserLogin", array(
"AppSessionID" =>$result['StartAppSessionResult']'SessionID'],
"LoginName" => "xxxxxxx",
"Password" => "xxxxxxxx",
"RetrieveSecurityGroups" => FALSE));
$client_cc = new nusoap_client('https://abc.com/abc.svc?wsdl', 'WSDL');
$obj = new stdClass();
$obj->CreditCardNumber = "4518169332998699";
$obj->ExpireMonth = 05;
$obj->ExpireYear = 2025;
$obj->CardNickname = "Test Card";
$obj->CardholderName = "John Doe";
$obj->Address = "123 Main Street";
$obj->City = "Anywhere";
$obj->State = "CA";
$obj->PostalCode = "92000";
$obj->Country ="Sandeep";
$parameter= array("CreditCardSubmission" => $obj);
$result3 = $client_cc->call(
'SubmitCreditCardInformation', array($result['UserLoginResult']['SessionID']), $parameter);
Below is the exception I'm getting from the service: "Object reference not set to an instance of an object." when i print_r($result3);
Array
(
[faultcode] => a:InternalServiceFault
[faultstring] => Array
(
[!xml:lang] => en-US
[!] => Object reference not set to an instance of an object.
)
[detail] => Array
(
[ExceptionDetail] => Array
(
[HelpLink] =>
[InnerException] =>
[Message] => Object reference not set to an instance of an object.
[StackTrace] => at Viad.Services.Public.GES.v1.OrderService.SubmitCreditCardInformation(String applicationSessionId, CreditCardSubmission request) in c:\SVN\Viad.GES.Services\Branches\PublicServices_v1\Viad.Services.Public.GES\v1\OrderService.svc.cs:line 1246
at SyncInvokeSubmitCreditCardInformation(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)
[Type] => System.NullReferenceException
)
)
)
Any help would be greatly appreciated!
Thanks!