Я довольно сильно достигла своих пределов. У меня есть служба WCF, которая работает, когда я запускаю локально с помощью Visual Studio 2013. Я звоню в службу из приложения WPF.Служба WCF выдает внутреннюю ошибку сервера
Я проверил другие темы, которые, похоже, указывают на настройки конфигурации, и я пробовал их без везения.
Вот код моей службы.
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceContract]
public class VerificationRequest
{
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "send", RequestFormat = WebMessageFormat.Json)]
public Stream Send(PatientVerificationRequest data)
{
try
{
using (StreamWriter sw = File.AppendText("RequestLog"))
{
sw.WriteLine("Request Received");
}
if (data == null)
{
return new MemoryStream(Encoding.UTF8.GetBytes("<html><body>Post Successful</body></html>"));
}
// Put back into json format
string json = JsonConvert.SerializeObject(data);
using (StreamWriter sw = File.AppendText("RequestLog"))
{
sw.WriteLine(json);
}
// Log the request to the database
// First, the actual json string
var jsonId = PhoenixProcedure.CreateCloudVerificationRequest(json);
var cvrId = PhoenixProcedure.CreateCloudVerificationRequest(data);
if (WebOperationContext.Current != null)
{
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.OK;
WebOperationContext.Current.OutgoingResponse.ContentType = "text/html";
}
return new MemoryStream(Encoding.UTF8.GetBytes("<html><body>Post Successful</body></html>"));
}
catch (Exception ex)
{
Logger.Instance.WriteEvent(new LogEntry
{
Application = "DocumentVerification",
EntryType = LoggingEventType.Error,
Error = ex,
Message = "Error Sending Verification Request",
Source = "Send",
SystemUserId = 8
});
}
return null;
}
И вот важные настройки в файле web.config.
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="http" maxBufferSize="20971520" maxBufferPoolSize="20971520" maxReceivedMessageSize="20971520">
<readerQuotas maxDepth="32"
maxArrayLength="200000000"
maxStringContentLength="200000000"/>
</binding>
</webHttpBinding>
<basicHttpBinding>
<binding name="efHttp" maxReceivedMessageSize="20000000"
maxBufferSize="20000000"
maxBufferPoolSize="20000000">
<readerQuotas maxDepth="32"
maxArrayLength="200000000"
maxStringContentLength="200000000"/>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="DocVerify.VerificationRequest" behaviorConfiguration="ServiceBehavior">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="http" name="http" contract="DocVerify.VerificationRequest"/>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
Вот App.config в вызывающем приложении.
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="WCFHttpBehavior">
<callbackDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="webhttp">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="WCFHttpBinding" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
<readerQuotas maxArrayLength="2147483647" maxDepth="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647" />
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="WCFWebBinding" openTimeout="00:10:00" closeTimeout="00:10:00" sendTimeout="00:10:00" receiveTimeout="00:30:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
<binding name="VerificationBinding" allowCookies="true"
maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
<readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
</binding>
</webHttpBinding>
</bindings>
<client>
<endpoint address="http://PSICTSWEB01:65530/DocVerify/VerificationRequest.svc"
binding="webHttpBinding" bindingConfiguration="VerificationBinding"
contract="DocVerify.VerificationRequest"
behaviorConfiguration="webhttp"/>
</client>
И, наконец, код вызова службы.
DocVerify.VerificationRequest rs = new VerificationRequestClient();
rs.Send(new PatientVerificationRequest
{
request_type = (int)PatientVerificationRequestType.Full,
patient_id = 120053,
fname = "FirstName",
lname = "LastName",
gender = "M",
dob_month = 2,
dob_day = 14,
dob_year = 1982,
address1 = "10 Main St.",
city = "Hampton",
state = "VA",
zipcode = "23669",
reported_income = 54000,
primary_insurance_name = "United Health Care",
primary_policy_number = "PN123456",
primary_group_number = "GN67890",
primary_policy_holder_fname = "FirstName",
primary_policy_holder_lname = "LastName"
});
Служба немедленно создает журнал при вызове. Файл журнала никогда не создается, поэтому перед вызовом фактического вызова возникает ошибка, но возникает во время метода rs.Send().
Я проверил разрешения на сервере, чтобы убедиться, что права на создание файла журнала верны. Мне кажется, что файлы конфигурации в порядке, но что-то явно не так. У кого-нибудь есть идеи?
NEW INFO: Я включил WCF Tracing и я получаю эту ошибку:
The message with To ' http://psictsweb01.psi.pri:65530/DocVerify/VerificationRequest.svc/Send ' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree.
Используя эту информацию, я изменил информацию о web.config конечной точки:
<binding name="VerificationBinding" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000"> <readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/> </binding>
<service name="DocVerify.VerificationRequest" behaviorConfiguration="ServiceBehavior">
<endpoint address="http://PSICTSWEB01:65530/DocVerify/VerificationRequest.svc"
binding="webHttpBinding" bindingConfiguration="VerificationBinding" name="VerificationBinding" contract="DocVerify.VerificationRequest" behaviorConfiguration="webhttp"/>
</service>
В приложении обязательными и конечными точками являются:
<binding name="VerificationBinding" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000"> <readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/> </binding>
<endpoint address="http://PSICTSWEB01:65530/DocVerify/VerificationRequest.svc"
binding="webHttpBinding" bindingConfiguration="VerificationBinding"
contract="DocVerify.VerificationRequest"
behaviorConfiguration="webhttp"/>
Точки совпадения. Что я делаю не так?
Посмотрите в журнале событий Windows на веб-сервере, где вы получите эту ошибку, вы должны увидеть запись в журнале приложений, которая показывает ошибку, которая будет иметь полную трассировку стека. Вы также можете включить ведение журнала wcf, google. – Wjdavis5
Поскольку вы включаете исключения в вину, у вас должна быть дополнительная информация, которая поможет вам. Вот полезная статья http: //www.codeproject.com/Articles/799258/WCF-Exception-FaultException-FaultContract –
Я добавил в службу WCF запись в службу. Спасибо за отличную идею! Журнал сообщает мне, что конечные точки не совпадают, но я думаю, что они это делают. Я редактировал свой пост с помощью секции «NEW INFO», которая показывает информацию. Все еще работала над этим, но все еще проигрывала. –