Веб-сервис вернул ошибку:charset=UTF-8 ответного сообщения не соответствует типу содержимого привязки (text/xml; charset=utf-8

Я пытаюсь сделать сервис PSI Extension для sharepoint 2013, но некоторые ошибки показа в клиенте, PSI Extension dll корректно работает, но.... Пожалуйста, помогите мне ~~~!!!

Ошибки:

Произошло необработанное исключение типа "System.ServiceModel.ProtocolException" в mscorlib.dll Дополнительная информация: Тип содержимого text/html; charset=UTF-8 ответного сообщения не соответствует типу содержимого привязки (text/xml; charset=utf-8). При использовании пользовательского кодировщика убедитесь, что метод IsContentTypeSupported реализован правильно. Первые 1024 байта ответа были: ' #content{ FONT-SIZE: 0.7em; Нижняя часть: 2em; MARGIN-LEFT: 30px} ТЕЛО {MARGIN-TOP: 0px; MARGIN-LEFT: 0px; ЦВЕТ: # 000000; Шрифтовая семья: Вердана; ЦВЕТ ФОНА: белый} P {MARGIN-TOP: 0px; Дно: 12px; ЦВЕТ: # 000000; FONT-FAMILY: Verdana} PRE {ГРАНИЦА-ПРАВО:

f0f0e0 1px solid; ВПРАВО-ПРАВО: 5px; BORDER-TOP: # f0f0e0 1px solid;

MARGIN-TOP: -5px; PADDING-LEFT: 5 пикселей; Размер шрифта: 1.2em; Нижняя часть: 5 пикселей; ГРАНИЦА-ВЛЕВО: # f0f0e0 1px solid; PADDING-TOP: 5 пикселей; BORDER-BOTTOM:

f0f0e0 1px solid; FONT-FAMILY: Курьер Новый; ЦВЕТ ФОНА: # e5e5cc}.heading1 {MARGIN-TOP: 0px; PADDING-LEFT:

15px; Вес шрифта: нормальный; Размер шрифта: 26 пикселей; Дно: 0px; Нижняя часть: 3 пикселя; MARGIN-LEFT: -30px; ШИРИНА: 100%; ЦВЕТ: #ffffff; PADDING-TOP: 10 пикселей; Шрифтовая семья: Tahoma; ФОН-ЦВЕТ: #003366}.intro{MARGIN-LEFT: -15px} Служба TimesheetExt<'. Трассировка стека сервера: в System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse (запрос HttpWebRequest, ответ HttpWebResponse, HttpChannelFactory 1 factory, WebException responseException, ChannelBinding channelBinding) at System.ServiceModel.Channels.HttpChannelFactory1.HttpRequestChannel.HttpChannelRequest.WaitForReply(тайм-аут TimeSpan) в System.ServiceModel.Channels.RequestChannel.Request(сообщение-сообщение, тайм-аут TimeSpan) в System.ServiceModel.Dispatcher.RequestChannelBinder.odel.service.Request. Channels.ServiceChannel.Call (действие String, логическое одностороннее действие, операция ProxyOperationRuntime, Object [] ins, Object [] ауты, тайм-аут TimeSpan) в System.ServiceModel.Channels.ServiceChannelProxy.InvokeService (IMethodCallMessage methodCalltime, операция System.SystemTimeSlayTime. Channels.ServiceChannelProxy.Invoke (сообщение IMessage)

Исключение, переброшенное в [0]: в System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage (IMessage reqMsg, IMessage retMsg) в System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgDataTextSimeTextSimeText) в Int32) ITimesheetExt.ReadTimesheetListForCurrentUser(ReadTimesheetListForCurrentUserRequest запрос) на TestTimesheetExt.SvcTimesheetExt.TimesheetExtClient.TestTimesheetExt.SvcTimesheetExt.ITimesheetExt.ReadTimesheetListForCurrentUser(ReadTimesheetListForCurrentUserRequest запрос) в D:\Project\C#***\Source\PSIExtension\TestTimesheetExt\Service References\SvcTimesheetExt\Reference.cs: строка 1529 в TestTimesheetExt.SvcTimesheetExt.TimesheetExtClient.ReadTimesheetListForCurrentUser(String pwaUrl) в d:\Project\C#***\Source\PSIExtension\TestTimesheetExt\ Сервисные ссылки \ SvcTimesheetExt.St. 15.Em.Em.Sec.Temp.Text.Set.MeE.Set.Text.Tess.Text.Set.Set.Text.Set.Text.Set.Text.Set.Set.Text.Set.Em.Set.Sec35 (Ссылка. Строка [] args) в d:\Project\C#***\Source\PSIExtension\TestTimesheetExt\Program.cs: строка 37

источники

1. PSI Extension config.

private static void SetClientEndpoints(string pwaUrl)
    {
        const int MAXSIZE = 500000000;
        const string svcRouter = "_vti_bin/PSI/ProjectServer.svc";

        Uri pwaUri = GetServerUri(pwaUrl);

        pwaUrl = pwaUri.Scheme + Uri.SchemeDelimiter + pwaUri.Host + ":"
            + pwaUri.Port + pwaUri.AbsolutePath;
        //Console.WriteLine("URL: {0}", pwaUrl);

        BasicHttpBinding binding = null;

        if (pwaUri.Scheme.Equals(Uri.UriSchemeHttps))
        {
            // Create binding for HTTPS.
            binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
        }
        else
        {
            // Create binding for HTTP.
            binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
        }

        binding.Name = "basicHttpConf";
        binding.AllowCookies = true;
        binding.MessageEncoding = WSMessageEncoding.Text;

        binding.OpenTimeout = TimeSpan.FromHours(1);
        binding.ReceiveTimeout = TimeSpan.FromHours(1);
        binding.SendTimeout = TimeSpan.FromHours(1);

        // If the TransferMode is buffered, the MaxBufferSize and 
        // MaxReceived MessageSize must be the same value.
        binding.TransferMode = TransferMode.Buffered;
        binding.MaxBufferSize = MAXSIZE;
        binding.MaxReceivedMessageSize = MAXSIZE;
        binding.ReaderQuotas.MaxArrayLength = MAXSIZE;
        binding.ReaderQuotas.MaxNameTableCharCount = MAXSIZE;
        binding.TextEncoding = UTF8Encoding.UTF8;

        binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
      //  binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.Ntlm;
        binding.Security.Transport.Realm = "";

        // The endpoint address is the ProjectServer.svc router for all public PSI calls.
        EndpointAddress address = new EndpointAddress(pwaUrl + svcRouter);

        resourceClient = new SvcResource.ResourceClient(binding, address);
        resourceClient.ChannelFactory.Credentials.Windows.AllowedImpersonationLevel
            = TokenImpersonationLevel.Impersonation;
        resourceClient.ChannelFactory.Credentials.Windows.AllowNtlm = true;

        timesheetClient = new SvcTimeSheet.TimeSheetClient(binding, address);
        timesheetClient.ChannelFactory.Credentials.Windows.AllowedImpersonationLevel
            = TokenImpersonationLevel.Impersonation;
        timesheetClient.ChannelFactory.Credentials.Windows.AllowNtlm = true;
    }


2. Web.config   

    <system.serviceModel>
    <diagnostics>
      <messageLogging 
      logEntireMessage="true" 
      logMalformedMessages="true" 
      logMessagesAtServiceLevel="true" 
      logMessagesAtTransportLevel="true" 
      maxMessagesToLog="3000" 
      maxSizeOfMessageToLog="4194304" />
    </diagnostics>
    <bindings>
       <basicHttpBinding>
         <binding name="extensionBasicHttpConf" 
             closeTimeout="00:01:00" 
             openTimeout="00:01:00" 
             receiveTimeout="00:10:00" 
             sendTimeout="00:01:00" 
             allowCookies="true" 
             maxBufferSize="4194304" 
             maxReceivedMessageSize="500000000" 
             textEncoding="utf-8" 
             transferMode="StreamedResponse" 
             messageEncoding="Text">
           <security mode="TransportCredentialOnly">
             <transport clientCredentialType="Ntlm" 
             proxyCredentialType="None" 
             realm="" />
           </security>
         </binding>
         <binding name="mexHttpBinding" 
            transferMode="StreamedResponse" useDefaultWebProxy="true">
           <security mode="TransportCredentialOnly">
             <transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" />
           </security>
         </binding>
       </basicHttpBinding>
     </bindings>

     <behaviors>
      <serviceBehaviors>
        <behavior name="PSIExtensionServiceBehavior">
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceMetadata httpGetEnabled="true" />       
        </behavior>
      </serviceBehaviors>

    </behaviors>
    <services>

      <service name="Microsoft.SDK.Project.Samples.PSIExtensions.TimesheetExt"
               behaviorConfiguration="PSIExtensionServiceBehavior">
        <endpoint address="http://***.com/_vti_bin/psi/PSIExtensions.svc"
                  binding="basicHttpBinding"
                  bindingConfiguration="extensionBasicHttpConf"
                  contract="Microsoft.SDK.Project.Samples.PSIExtensions.ITimesheetExt" />
        <endpoint address="mex"
                  binding="basicHttpBinding"
                  bindingConfiguration="mexHttpBinding"
                  name="mex"
                  contract="IMetadataExchange" />
      </service>      

    </services>

  </system.serviceModel>



3. app.config (client)

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <endpointBehaviors>
        <behavior name="basicHttpBehavior">
          <clientCredentials>
            <windows allowedImpersonationLevel="Impersonation"/>
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpConf" sendTimeout="01:00:00" maxBufferSize="500000000"
          maxReceivedMessageSize="500000000" messageEncoding="Text" textEncoding="utf-8" >
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="500000000" />
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Ntlm" realm="" />
          </security>
        </binding>      
      </basicHttpBinding>
    </bindings>
    <client>    
      <endpoint  address="http://***.com/_vti_bin/psi/PSIExtensions.svc"
         behaviorConfiguration="basicHttpBehavior" binding="basicHttpBinding" bindingConfiguration="basicHttpConf"
        contract="SvcTimesheetExt.ITimesheetExt" name="basicHttp_TimesheetExt" />
    </client>
  </system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

Кто-нибудь, кто-нибудь, помогите мне.. Спасибо.

0 ответов

Другие вопросы по тегам