简体   繁体   English

我的Silverlight / WCF配置有什么问题

[英]What is wrong with my Silverlight / WCF Configuration

I've been struggling for a few hours I admit. 我承认我已经挣扎了几个小时。 I must be missing something with the Bindings/Configuration between my Silverlight application and WCF web service. 我的Silverlight应用程序和WCF Web服务之间的绑定/配置一定缺少一些东西。 It was working for awhile, but I must have accidentally changed some settings and I can't get it to work anymore. 它已经工作了一段时间,但我一定不小心更改了一些设置,但现在无法正常工作了。

In Visual Studio when I debug I have both the Service and Silverlight application launch at the same time, I have Windows authentication disabled in the web.config files for debugging. 在Visual Studio中,当我调试时,同时启动了Service和Silverlight应用程序,并在web.config文件中禁用了Windows身份验证以进行调试。 When I deploy, I go back and change my Configuration files to enable Windows security/transport so I can get user credentials on the web service side. 部署后,我返回并更改配置文件以启用Windows安全性/传输,以便可以在Web服务端获取用户凭据。

Now when I deploy both the WCF service and the Silverlight application to a different machine using IIS, I get an error "Not Found" from Silverlight when it attempts to contact the WCF service. 现在,当我使用IIS将WCF服务和Silverlight应用程序部署到另一台计算机上时,当Silverlight尝试联系WCF服务时,我会从错误消息“找不到”。 Could someone explain to me the different configuration files that exist and what each should be pointing to? 有人可以向我解释存在的不同配置文件以及每个文件应指向什么吗? Here are my configuration files in their respective locations: 这是我在各自位置的配置文件:

wwwroot\\webserviceapp\\web.config wwwroot \\ webserviceapp \\ web.config

<?xml version="1.0" encoding="UTF-8"?>

<bindings>
  <basicHttpBinding>
    <binding name="BasicHttpEndpointBinding">
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Windows"/>
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
<services>
  <service behaviorConfiguration="ServiceBehavior" name="WebserviceName.Service1">
    <endpoint address="" binding="basicHttpBinding"
      bindingConfiguration="BasicHttpEndpointBinding"
      name="BasicHttpEndpoint" contract="WebserviceName.IService1">
    </endpoint>
  </service>
</services>

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

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />

wwwroot\\web.config - this is the web.config for silverlight I guess? wwwroot \\ web.config-我猜这是Silverlight的web.config?

<?xml version="1.0" encoding="UTF-8"?>

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                      <security mode="TransportCredentialOnly">
                        <transport clientCredentialType="Windows" />
                      </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://<<<ip_to_machine>>>/webserviceapp/Service1.svc" 
            binding="basicHttpBinding" 
            bindingConfiguration="BasicHttpEndpoint" 
            contract="ServiceReference1.IService1"
            name="BasicHttpEndpoint" />
    </client>
</system.serviceModel>
<system.webServer>
    <defaultDocument>
        <files>
            <add value="ProjectTestPage.html" />
        </files>
    </defaultDocument>
</system.webServer>

wwwwroot\\ClientBin\\SilverlightApp.xap (the ServiceReferences.ClientConfig file): wwwwroot \\ ClientBin \\ SilverlightApp.xap(ServiceReferences.ClientConfig文件):

<configuration>
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpEndpoint" maxBufferSize="2147483647"
                maxReceivedMessageSize="2147483647">
                                <security mode="TransportCredentialOnly" />
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://<<<ip_to_machine>>>/webserviceapp/Service1.svc" 
                binding="basicHttpBinding"
            bindingConfiguration="BasicHttpEndpoint" 
            contract="ServiceReference1.IService1"
            name="BasicHttpEndpoint" />
    </client>
</system.serviceModel>

These are the three configuration files which seem to drive everything, unless I am wrong? 这是三个似乎可以驱动所有内容的配置文件,除非我错了? Since I develop on one environment and deploy to another it seems like I must change these files to point to the right resources. 由于我是在一个环境上开发并部署到另一个环境,因此似乎必须更改这些文件以指向正确的资源。 When I hit my Silverlight application after I've deployed it to the new machine I get the application loading. 将我的Silverlight应用程序部署到新计算机上后,我将其加载。 Once it finishes loading, the first web service call it makes fails with exception and I get this in the Chrome Console: 加载完成后,它进行的第一个Web服务调用会失败,并出现异常,我可以在Chrome控制台中找到它:

Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://<<<ip_to_machine>>>/webserviceapp/Service1.svc
Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://<<<ip_to_machine>>>/webserviceapp/Service1.svc
Uncaught Error: Unhandled Error in Silverlight Application An exception occurred during the operation, making the result invalid.  Check InnerException for exception details.   at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
   at Project.ServiceReference1.GetAllNewsCompletedEventArgs.get_Result()
   at Project.View.Home1.ClientGetAllNewsCompleted(Object pSender, GetAllNewsCompletedEventArgs pEventArgs)
   at Project.ServiceReference1.Service1Client.OnGetAllNewsCompleted(Object state)

I'm like 99% certain that the Service is NEVER hit. 我想99%可以肯定该服务从未受到打击。 I have a log statement at the very top of the function which is being called and it never logs anything. 我在被调用的函数的最顶部有一条日志语句,它从不记录任何内容。

IIS Configuration: Web Service Authentication: Anonymous = Disabled ASP.NET Impersonation = Disabled Windows Authentication = Enabled IIS配置:Web服务身份验证:匿名=禁用ASP.NET模仿=禁用Windows身份验证=启用

Default Web Site (where my silverlight app is hosted): Anonymous = Disabled ASP.NET Impersonation = Disabled Windows Authentication = Enabled 默认网站(托管我的Silverlight应用程序的网站):匿名=禁用ASP.NET模拟=禁用Windows身份验证=启用

Anyone have any suggestions, or need anymore information from me to help debug? 任何人有任何建议,或需要我提供更多信息以帮助调试?

EDIT: It is worth noting that I am able to navigate to the service from a different machine and see the service wsdl just fine. 编辑:值得注意的是,我能够从另一台机器导航到该服务,并看到该服务wsdl很好。 For example: 例如:

http://ipaddress/webserviceapp/Service1.svc

I can see this just fine, no errors. 我可以看到这很好,没有错误。

I think the answer is pretty simple. 我认为答案很简单。 The error I was receiving is a very generic error. 我收到的错误是一个非常普通的错误。 The proper thing to do in this instance is to use Fiddler which will tell you EXACTLY what the error is. 在这种情况下,正确的做法是使用Fiddler,它将准确地告诉您错误是什么。 In my case, Trace logging wasn't working properly due to the service not loading properly. 就我而言,由于服务无法正确加载,跟踪日志记录无法正常工作。 However, Fiddler was able to give me the exact exception messages which led me to resolve the problem quickly and easily. 但是,Fiddler能够给我确切的异常消息,这使我能够快速,轻松地解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM