https://webservice.kareo.com/services/soap/2.1/KareoServices.svc?wsdlでサービスの SOAP クライアントを作成しようとしてい ます。
サービスが提供する型 ( _getTypes) と関数 ( _getFunctions)を照会しました。以下は、実行しようとしている「GetPatients」操作の型構造です。
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;
.
.
.
}
関数の定義は次のとおりです。
GetPatientsResponse GetPatients(GetPatients $parameters)
以下は、Web サービスの「GetPatients」操作を使用しようとする私の php コードです。
<?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);
}
?>
これは私がサービスから得ている例外です:
"オブジェクト参照がオブジェクト インスタンスに設定されていません。"
次の行で例外がスローされます。
$presponse=$client->GetPatients($getpatientreq)
例外メッセージ全体を次に示します。
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"
これは私が書いている最初の SOAP クライアントです。これを修正するための助けは役に立ちます。