PHP调用.Net webservice [英] PHP call to .Net webservice

查看:68
本文介绍了PHP调用.Net webservice的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从PHP发送一个在.NET Web服务中定义为datacontract的自定义对象。我试图通过SOAP实现这一目标。这是我的datacontract。

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)



这是我的PHP代码。


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);





以下是我从服务中获得的异常:对象引用未设置为对象的实例。当我print_r($ result3);



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!

推荐答案

result2 =
result2 =


client-> call( UserLogin,array(
AppSessionID =>
client->call("UserLogin", array( "AppSessionID" =>


result [' StartAppSessionResult'] ' SessionID'],
LoginName => xxxxxxx
P assword => xxxxxxxx
RetrieveSecurityGroups =>假));

result['StartAppSessionResult']'SessionID'], "LoginName" => "xxxxxxx", "Password" => "xxxxxxxx", "RetrieveSecurityGroups" => FALSE));


这篇关于PHP调用.Net webservice的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆