У меня есть служба WCF
[ServiceContract(Name = "Test")]
public interface ITest {
[OperationContract]
string test1();
}
[DataContract]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single, UseSynchronizationContext = false)]
public class csTest : ITest {
public string test1() {
Thread.Sleep(60000);
return "test1";
}
}
запустить их
ServiceHost TestHost= new ServiceHost(typeof(HostHCS.Test.csTest), new Uri("http://127.0.0.1:8150/Test"));
ServiceConfigureHttp(TestHost, crtSMBHttp("127.0.0.1","Test","8150"), crtSDB(), typeof(HostHCS.Test.ITest), crtBndHttp(), ip, "Test");
TestHost.Open();
private void ServiceConfigureHttp(ServiceHost service, ServiceMetadataBehavior serviceMetadataBehavior, ServiceDebugBehavior serviceDebugBehavior, Type serviceType, BasicHttpBinding bind, string ip, string servName) {
service.Description.Behaviors.Remove(typeof(ServiceMetadataBehavior));
service.Description.Behaviors.Add(serviceMetadataBehavior);
service.Description.Behaviors.Remove(typeof(ServiceDebugBehavior));
service.Description.Behaviors.Add(serviceDebugBehavior);
service.AddServiceEndpoint(serviceType, new WSHttpBinding(),"");
service.AddServiceEndpoint(
System.ServiceModel.Description.ServiceMetadataBehavior.MexContractName,
System.ServiceModel.Description.
MetadataExchangeBindings.CreateMexHttpBinding(),
"http://127.0.0.1:8150/Test/mex");
}
private BasicHttpBinding crtBndHttp() {
BasicHttpBinding binding = new BasicHttpBinding();
binding.MaxReceivedMessageSize = Int32.MaxValue;
XmlDictionaryReaderQuotas readerQuotas = new XmlDictionaryReaderQuotas();
readerQuotas.MaxArrayLength = Int32.MaxValue;
readerQuotas.MaxStringContentLength = Int32.MaxValue;
readerQuotas.MaxBytesPerRead = Int32.MaxValue;
readerQuotas.MaxDepth = Int32.MaxValue;
binding.ReaderQuotas = readerQuotas;
binding.MaxBufferPoolSize = Int32.MaxValue;
binding.OpenTimeout = new TimeSpan(1, 00, 0);
binding.CloseTimeout = new TimeSpan(1, 00, 0);
binding.SendTimeout = new TimeSpan(1, 00, 0);
binding.ReceiveTimeout = new TimeSpan(1, 00, 0);
return binding;
}
private ServiceMetadataBehavior crtSMBHttp(string ip, string servName,string port) {
ServiceMetadataBehavior myServiceMetadataBehavior = new ServiceMetadataBehavior();
myServiceMetadataBehavior.HttpGetEnabled = true;
myServiceMetadataBehavior.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
return myServiceMetadataBehavior;
}
Мой php код
<?php
try{
ini_set('default_socket_timeout', 600); //120/// 6000//60000
$client = new SoapClient(
'http://127.0.0.1:8150/Test?wsdl',
array(
'soap_version' => SOAP_1_2,
'cache_wsdl' => WSDL_CACHE_NONE,
'trace' => 1,
'exception' => 1,
'keep_alive' => 0,
'connection_timeout' => 60000//500000
));
$webService = $client->test1();
} catch (Exception $e) {
print 'Caught exception: '. $e->getTraceAsString(). "<br/>";
print 'Caught exception: '. $e->getMessage(). "<br/>";
var_dump($client->__getLastRequestHeaders());
print "<br/>";
var_dump($client->__getLastRequest());
print "<br/>";
var_dump($client->__getLastResponse());
print "<br/>";
}
?>
очень быстро возвращает результат
Пойманное исключение: # 0 [внутренняя функция]: SoapClient -> __ doRequest ('__ call (' test1 ', Array) # 2 {main}
Пойманное исключение: Ошибка при получении заголовков http
string (204) "POST / Test HTTP / 1.1 Host: 127.0.0.1:8150 Соединение: закрыть User-Agent: PHP-SOAP / 7.3.2 Тип содержимого: application / soap + xml; charset = utf-8; действие= "http://tempuri.org/Test/test1" Content-Length: 186"
string (186) ""
NULL
То есть нет вызова метода службы, поскольку результат должен быть получен только через минуту. в чем может быть проблема и что я делаю не так?