问题描述
我试图为
我查询了类型(_ getTypes)和函数( _getFunctions)。以下是我正在尝试执行的GetPatients操作的类型结构:
struct GetPatients {
GetPatientsReq请求;
}
struct GetPatientsReq {
PatientFieldsToReturn Fields;
PatientFilter过滤器
}
struct PatientFieldsToReturn {
boolean AddressLine1;
boolean AddressLine2;
boolean年龄;
。
。
。
}
struct PatientFilter {
string CollectionCategoryName;
string DefaultCasePayerScenario;
string FirstName;
。
。
。
}
struct GetPatientsResponse {
GetPatientsResp GetPatientsResult;
}
struct GetPatientsResp {
ArrayOfPatientData Patients;
}
struct ArrayOfPatientData {
PatientData PatientData;
}
struct PatientData {
string AddressLine1;
string AddressLine2;
字符串调整;
string年龄;
。
。
。
}
功能定义是:
$ b $ getPatientsResponse GetPatients(GetPatients $ parameters)
以下是我的php代码,尝试使用Web服务的GetPatients操作:
<?php
$ url =https://webservice.kareo.com/services/soap/2.1/KareoServices ?.SVC WSDL;
$ client = new SoapClient($ url);
/ *假用户,密码,键* /
$ CustomerKey ='xxx';
$ User ='rmg15';
$ Password ='pass77';
$ PatientID ='1234';
$ authheader = array(CustomerKey=> $ CustomerKey,User=> $ User,Password=> $ Password);
$ header = new SoapHeader(https://webservice.kareo.com/services/soap/2.1/,AuthHeader,$ authheader,false);
$ client-> __ setSoapHeaders(array($ header));
/ *它工作到这一点,因为我能够成功执行__getTypes,__getFunctions操作。 * /
$ filter = array(FirstName=>rmg15);
$ fields = array(age=>true);
$ request = array(PatientFieldsToReturn=> $ fields,PatientFilter=> $ filter);
$ getpatientreq = array(GetPatientsReq=> $ request);
try
{
$ presponse = $ client-> GetPatients($ getpatientreq);
}
catch(异常$ ex){
var_dump($ ex-> faultcode,$ ex-> faultstring,$ ex-> faultactor ,$ ex-> detail,$ ex-> _name,$ ex-> headerfault);
}
?>
这是我从服务中获取的例外:
对象引用未设置为对象的实例。
异常抛出此行:
$ presponse = $ client-> GetPatients($ getpatientreq)
以下是整个异常消息:
$ #
[ExceptionDetail] =>
object(stdClass)#8(5){
[HelpLink] =>
NULL
[InnerException] =>
NULL
[Message] =>
string(53)对象引用未设置为对象的实例。
[StackTrace] =>在C:\BuildAgent\work\309fd08b06e24475\Superbill\Software\Application\KareoServicesWCF\2.1\KareoServicesWCF\\中的KareoServicesWCF.KareoServices.GetPatients(GetPatientsReq请求)中的
字符串(755)在Object.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance,Object [] inputs,Object [])上的
在SyncInvokeGetPatients(Object,Object [],Object []) & outputs)
在System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
在System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
在System.ServiceModel .Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
在System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
[Type] =>
string(29)System.NullReferenceException
这是第一个SOAP客户端, m写作。任何解决这个问题的帮助将是有用的。
找到解决方案。感谢Ankit Jain在
$ wsdl ='https://webservice.kareo.com/services/soap/2.1/KareoServices.svc?wsdl';
$ client = new SoapClient($ wsdl,array('trace'=> 1,'exceptions'=> 1));
//将数据存储在stdClass`enter代码的对象中
$ requestHeader = new stdClass;
$ requestHeader-> CustomerKey ='xxx';
$ requestHeader-> User ='yyy';
$ requestHeader-> Password ='int123';
$ filter = new stdClass;
$ filter-> PracticeName =American Surgery Associates;
$ fields = new stdClass;
$ fields-> ID = true;
$ fields-> PracticeName = true;
$ fields-> PatientFullName = true;
$ request = new stdClass;
$ request-> RequestHeader = $ requestHeader;
$ request-> Filter = $ filter;
$ request-> Fields = $ fields;
//调用SOAP函数
$ response = $ client-> GetPatients(array('request'=> $ request));
print_r($ response);
I'm trying to write a SOAP client for the service at https://webservice.kareo.com/services/soap/2.1/KareoServices.svc?wsdl
I queried the types (_getTypes) and functions (_getFunctions) that the service offers . Below is the type structure for the 'GetPatients' operation I'm trying to perform:
struct GetPatients {
GetPatientsReq request;
}
struct GetPatientsReq {
PatientFieldsToReturn Fields;
PatientFilter Filter;
}
struct PatientFieldsToReturn {
boolean AddressLine1;
boolean AddressLine2;
boolean Age;
.
.
.
}
struct PatientFilter {
string CollectionCategoryName;
string DefaultCasePayerScenario;
string FirstName;
.
.
.
}
struct GetPatientsResponse {
GetPatientsResp GetPatientsResult;
}
struct GetPatientsResp {
ArrayOfPatientData Patients;
}
struct ArrayOfPatientData {
PatientData PatientData;
}
struct PatientData {
string AddressLine1;
string AddressLine2;
string Adjustments;
string Age;
.
.
.
}
The function definition is:
GetPatientsResponse GetPatients(GetPatients $parameters)
Below is my php code that tries to use the web service's 'GetPatients' operation:
<?php
$url="https://webservice.kareo.com/services/soap/2.1/KareoServices.svc?wsdl";
$client=new SoapClient($url);
/* fake user, password, key */
$CustomerKey='xxx';
$User='rmg15';
$Password='pass77';
$PatientID='1234';
$authheader=array("CustomerKey"=>$CustomerKey,"User"=>$User,"Password"=>$Password);
$header = new SoapHeader("https://webservice.kareo.com/services/soap/2.1/","AuthHeader", $authheader,false);
$client->__setSoapHeaders(array($header));
/* it works till this point because I was able to successfully perform the __getTypes, __getFunctions operations. */
$filter= array("FirstName"=>"rmg15");
$fields=array("age"=>"true");
$request=array("PatientFieldsToReturn"=>$fields,"PatientFilter"=>$filter);
$getpatientreq=array("GetPatientsReq"=>$request);
try
{
$presponse=$client->GetPatients($getpatientreq);
}
catch (Exception $ex) {
var_dump($ex->faultcode, $ex->faultstring, $ex->faultactor, $ex->detail, $ex->_name, $ex->headerfault);
}
?>
This is the exception I'm getting from the service:
"Object reference not set to an instance of an object."
The exception is thrown at this line:
$presponse=$client->GetPatients($getpatientreq)
Here is the entire exception message:
object(stdClass)#7 (1) {
["ExceptionDetail"]=>
object(stdClass)#8 (5) {
["HelpLink"]=>
NULL
["InnerException"]=>
NULL
["Message"]=>
string(53) "Object reference not set to an instance of an object."
["StackTrace"]=>
string(755) " at KareoServicesWCF.KareoServices.GetPatients(GetPatientsReq request) in c:\BuildAgent\work\309fd08b06e24475\Superbill\Software\Application\KareoServicesWCF\2.1\KareoServicesWCF\KareoServices.cs:line 497
at SyncInvokeGetPatients(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"]=>
string(29) "System.NullReferenceException"
This is the first SOAP client I'm writing. Any help in fixing this will be useful.
Found the solution. Thanks to Ankit Jain's reply at http://cgeers.com/2009/08/20/using-wcf-services-with-php-5/
$wsdl = 'https://webservice.kareo.com/services/soap/2.1/KareoServices.svc?wsdl';
$client = new SoapClient($wsdl, array('trace' => 1, 'exceptions' => 1));
// Store data in the object of stdClass`enter code here`
$requestHeader = new stdClass;
$requestHeader->CustomerKey = 'xxx';
$requestHeader->User = 'yyy';
$requestHeader->Password = 'int123';
$filter = new stdClass;
$filter->PracticeName = "American Surgery Associates";
$fields = new stdClass;
$fields->ID = true;
$fields->PracticeName = true;
$fields->PatientFullName = true;
$request = new stdClass;
$request->RequestHeader = $requestHeader;
$request->Filter = $filter;
$request->Fields = $fields;
// Call a SOAP function
$response = $client->GetPatients(array('request' => $request));
print_r($response);
这篇关于我的第一个SOAP客户端中的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!