在SOAP WSDL上获取500内部服务器错误调用PHP

时间:2015-11-07 07:47:42

标签: php web-services soap wsdl

我是PHP的新手,我有一些我需要发送数据的API。我使用下面的代码来做到这一点。

<?php  
// define variables and set to empty values
$name = $email = $city = $State_Province = $lastname = $ci_Address  ="" ;
$zipcode = $country = $phNumber = $ReasonforInquiry = $Scheduledate= $Comment = "" ;
$name = $_GET['firstname'];
$lastname=$_GET['lastname'];
$email=$_GET['email'];
$ci_Address=$_GET['StreetAddress']+$_GET['AddressLine2'];
$city=$_GET['city'];
$State_Province =$_GET['state'];
$zipcode = $_GET['zip'];
$country=$_GET['country'];
$phNumber=$_GET['ph1']+ "-"+$_GET['ph2']+ "-"+$_GET['ph3'];
$ReasonforInquiry=$_GET['ReasonforInquiry'];
$Scheduledate=$_GET['SD1']+ "-"+$_GET['SD2']+ "-"+$_GET['SD3'];
$Comment=$_GET['Comment'];
/// Create the standard SoapClient by pointing to the service's WSDL file/URL
$client = new SoapClient('https://test.com/test/external/v001/Patients/Patient.svc?wsdl');
/// ********************************************************
/// BEGIN: Sending and Receiving Objects
/// ********************************************************
/// The following displays how to call the service
/// First, create an object that matches the input object type expected.
class Patient
{
public $APIKey = '';
public $FirstName = '';
public $LastName = '';
public $MiddleName = '';
public $PhoneCC = '';
public $PhoneExt = '';
public $PhoneNumber = '';
public $EmailAddress = '';
public $MobileNumber = '';
public $Gender = '';
public $Age = '';
public $ResidingCountry = '';
public $Comments = '';
public $CI_Address = '';
public $CI_State_Province = '';
public $CI_City = '';
public $CI_Zip = '';
public $PTBNICOE_Name = '';
public $PTBNICOE_Address = '';
public $PTBNICOE_PhoneNumber = '';
public $PTBNICOE_Relationship_with_the_patient = '';
public $How_urgent_is_your_need = '';
public $Details_of_the_doctor_who_will_help_you_obtain_treatment_overseas = '';
public $Is_your_treatment_procedure_covered_by_insurance = '';
public $Do_you_have_a_Passport = '';
public $Have_you_ever_travelled_abroad = '';
public $Preferred_destination = '';
public $Preferred_destination_Yes_describe = '';
public $Desired_time_of_travel = '';
public $Number_of_people_accompanying_you = '';
public $Details_of_the_people_accompanying_you = '';
public $How_do_you_intend_to_pay_for_your_treatment = '';
public $Why_are_you_considering_treatment_abroad = '';
public $How_did_you_hear_about_us = '';
}
///Instantiate the parameter object to pass to the service.
$patient = new Patient();
///Set the values on the new object instance.
$patient->APIKey = '*******';
$patient->FirstName =  $name;
$patient->LastName  =  $lastname;
$patient->FirstName =  $email;
$patient->LastName  =  $ci_Address;
$patient->FirstName =  $city;
$patient->LastName  =  $State_Province;
$patient->FirstName =  $zipcode;
$patient->LastName  =  $country;
$patient->FirstName =  $phNumber;
$patient->LastName  =  $ReasonforInquiry;
$patient->Comments = $Comment;
//.//.//.
//$patient->How_did_you_hear_about_us = 'hear ';
/// Now, we create a variable array, named the same as the web method's parameter name.
/// This creates the proper parameter input for the web method call.
$patientParam = array('patientDC'=>$patient);
/// Call the web service and pass it the param array created above.
$PatientSaveResult = $client->Save($patientParam);
/// Get the result of the call.
$result = $PatientSaveResult->SaveResult;
/// Testing
if($result->IsSuccess)
echo('true');
else
echo($result->Error);
/// ********************************************************
/// END: Sending and Receiving Objects
/// 
?>

上面的代码在我的本地系统上工作正常,但是当我将更改移动到Staging服务器时。它停止工作。我调试了代码,发现由于下面的代码行而导致500内部错误:

$client = new SoapClient('https://test.com/test/external/v001/Patients/Patient.svc?wsdl');

我没有得到,如何解决它。它是服务器问题还是我可以通过代码修复它。请帮我。请指导我如何解决这个问题。

1 个答案:

答案 0 :(得分:0)

确认URL https://test.com/test/external/v001/Patients/Patient.svc?wsdl指向有效的WSDL。可能是您的本地开发站将此请求路由到您的Staging服务器没有的有效WSDL。例如,您的本地主机文件或DNS条目可能会将test.com请求路由到为开发目的而装配的本地服务器。