簡體   English   中英

從具有FaultException的WCF Web服務中消除tempuri

[英]Eliminating tempuri from a WCF Web Service which has FaultException

背景:

我最近將用戶請求的內部身份驗證添加到Web服務,並在身份驗證失敗的情況下引發了自定義FaultException。

FaultException自定義類型已被標記:

[DataContract(Namespace = ConstantConfig.ServiceNamespace, Name = "AuthenticationError")]
public class AuthenticationError

服務接口方法已被標記:

[OperationContract]
[FaultContract(typeof(AuthenticationError), Namespace = ConstantConfig.ServiceNamespace)]
ClientReport GetClientReport(DateTime from, DateTime to);

接口本身已被標記:

[ServiceContract(Namespace = ConstantConfig.ServiceNamespace)]
public interface IClientReportService

該接口的實現已被標記:

[ServiceBehavior(Namespace = ConstantConfig.ServiceNamespace)]
public class ClientReportService : IClientReportService

web.config和app.config都指向復制/粘貼的服務名稱空間。

盡管如此,盡管如此,我仍在生成tempuri.wsdl。 以下是wsdl的代表摘錄:

主要:

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://webservice.company.com/ClientReportService" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:i0="http://tempuri.org/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ClientReportService" targetNamespace="http://webservice.company.com/ClientReportService" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:import namespace="http://tempuri.org/" location="http://localhost:4319/ClientReportService.svc?wsdl=wsdl0" />
<wsdl:types>
<xsd:schema targetNamespace="http://webservice.company.com/ClientReportService/Imports">
    <xsd:import schemaLocation="http://localhost:4319/ClientReportService.svc?xsd=xsd0" namespace="http://webservice.company.com/ClientReportService" />
    <xsd:import schemaLocation="http://localhost:4319/ClientReportService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
</xsd:schema>
</wsdl:types>

天婦羅:

<wsdl:operation name="GetClientReport">
  <soap:operation soapAction="http://webservice.company.com/ClientReportService/IClientReportService/GetClientReport" style="document" />
  <wsdl:input>
    <soap:body use="literal" />
  </wsdl:input>
  <wsdl:output>
    <soap:body use="literal" />
  </wsdl:output>
  <wsdl:fault name="AuthenticationErrorFault">
    <soap:fault use="literal" name="AuthenticationErrorFault" namespace="" />
  </wsdl:fault>
</wsdl:operation>

我猜有些東西我還沒有被標記或標記不正確,但是很茫然。

有什么建議么?

嘗試這個

<endpoint address=""
                          binding="basicHttpBinding"
                          bindingNamespace="http://my.namespace.com"
                          contract=""/>
            </service>

事實證明,錯誤完全是我的。

在Web配置中,服務名稱與實際服務上的服務名稱不匹配。

實際服務(在.svc文件的標記內):

Service="Company.Client.Framework.ReportService.ClientReportService"

Web配置損壞

<service name="Company.Client.ReportService.ReportService">

更正了Web配置:

<service name="Company.Client.ReportService.ClientReportService">

在糾正此問題並重新生成WSDL之后,tempuri消失了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM