현재 WSHttpBinding을 사용하는 WCF 서비스에서 작업 중입니다. 지금까지이 서비스는 .NET 응용 프로그램과 잘 작동합니다. 그러나 PHP에서이 서비스를 사용할 때 오류가 발생합니다. 이 오류는 PHP가 WCF 서비스에 매개 변수로 null을 보내기 때문에 발생합니다.WSHttpBinding을 사용하는 PHP 호출 WCF 서비스
[DataContract]
public class RequestLostPassword
{
[DataMember(IsRequired = true)]
public string Email { get; set; }
[DataMember(IsRequired = true)]
public string NewPassword { get; set; }
[DataMember(IsRequired = true)]
public string CardNumber { get; set; }
[DataMember(IsRequired = true)]
public DateTime RequestStart { get; set; }
}
나는 전문가가 아니다 때문에, 그것은 나에게 동안을했다 :
[ServiceContract]
public interface IWebsite : IWcfSvc
{
[OperationContract]
[FaultContract(typeof(ServiceException))]
ResponseResult LostPassword(RequestLostPassword request);
}
매개 변수에 사용되는 데이터 계약은 다음과 같습니다 다음과 같이
서비스 계약 본다 PHP 코드를 작동 시키면 다음과 같은 스크립트를 작성하게됩니다.
$parameters = array(
'Email' => "[email protected]",
'NewPassword' => "test",
'CardNumber' => "1234567890",
'RequestStart' => date('c')
);
$svc = 'Website';
$port = '10007';
$func = 'LostPassword';
$url = 'http://xxx.xxx.xxx.xxx:'.$port.'/'.$svc;
$client = @new SoapClient(
$url."?wsdl",
array(
'soap_version' => SOAP_1_2,
'encoding'=>'ISO-8859-1',
'exceptions' => true,
'trace' => true,
'connection_timeout' => 120
)
);
$actionHeader[] = new SoapHeader(
'http://www.w3.org/2005/08/addressing',
'Action',
'http://tempuri.org/I'.$svc.'/'.$func,
true
);
$actionHeader[] = new SoapHeader(
'http://www.w3.org/2005/08/addressing',
'To',
$url,
true
);
$client->__setSoapHeaders($actionHeader);
$result = $client->__soapCall($func, array('parameters' => $parameters));
WCF 서비스에 매개 변수를 전달하지 않는 이유입니다. 매개 변수가 필요하지 않지만 괜찮은 서비스가 있습니다. 왜 이런 일이 일어 났는지 설명 할 수 있습니까? 저는 완벽한 PHP 멍청한 놈입니다. 단지 웹 사이트를 개발하는 녀석의 모범이되기를 바랍니다.