2011-10-04 80 views
1

我有一個WCF服務,需要多個端點(特別是json和SOAP)才能使其與Android和WP7設備兼容。使用SOAP端點的錯誤請求WCF Webservice

通過以下文件中的配置,我可以使用json端點通過Google Chrome訪問該服務,但是如果嘗試使用soap端點,則不能。使用Fiddler我得到404錯誤的地址http://liveandesor.web711.discountasp.net/wcf/SightingServiceRest.svc/json,雖然我得到了一個400錯誤錯誤的請求通過使用相同的地址,但在最後使用肥皂。

我試過使用this tutorial指示的配置,無濟於事。

爲什麼我在這裏做錯了?我怎樣才能解決這個問題?

任何幫助將不勝感激。謝謝你的時間! :d

下面是我使用的web.config文件:

<?xml version="1.0"?> 
<configuration> 
    <connectionStrings> 
    <!--Deploy--> 

    <add name="LiveAndesWCF" connectionString="data source=tcp:sql2k802.discountasp.net;Initial Catalog=SQL2008_832326_liveandes;User ID=SQL2008_832326_liveandes_user;Password=******; MultipleActiveResultSets=true" providerName="System.Data.SqlClient"/> 
    <add name="LiveAndes" connectionString="data source=tcp:sql2k802.discountasp.net;Initial Catalog=SQL2008_832326_liveandes;User ID=SQL2008_832326_liveandes_user;Password=****; MultipleActiveResultSets=true" providerName="System.Data.SqlClient"/> 

    </connectionStrings> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0"/> 
    <membership> 
     <providers> 
     <clear/> 
     <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="LiveAndes" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/> 
     </providers> 
    </membership> 
    </system.web> 
    <appSettings> 
    <!-- Deploy --> 

    <add key="mainPathDeployWCF" value="http://liveandesor.web711.discountasp.net/"/> 
    <add key="mainMachPathDeployWCF" value="e:\web\liveandesor\htdocs"/> 
    <add key="serverPath" value="e:\\web\\liveandesor\\htdocs"/> 
    <add key="imageBaseUrl" value="http://liveandesor.web711.discountasp.net/Content/UploadedImages/"/> 

    <!--<add key="mainMachPath" value="C:\Users\Rul\Documents\Universidad\2011'1\Taller de Especialidad\svn\Desarrollo\WEB\LiveAndesMVC\LiveAndesMVC"/>--> 
    </appSettings> 

    <system.serviceModel> 
    <protocolMapping> 
     <add scheme="http" binding="wsHttpBinding" /> 
    </protocolMapping> 


    <services> 
     <service name="LiveAndesWCF.SightingService"> 
     <endpoint address="soap" 
        bindingConfiguration="soapBinding" 
        binding="basicHttpBinding" 
        contract="LiveAndesWCF.ISightingService"/> 
     <endpoint address="json" 
        binding="webHttpBinding" 
        behaviorConfiguration="jsonBehavior" 
        contract="LiveAndesWCF.ISightingService"/> 
     </service> 
     <service name="LiveAndesWCF.UserService"> 
     <endpoint address="soap" 
        bindingConfiguration="soapBinding" 
        binding="basicHttpBinding" 
        contract="LiveAndesWCF.IUserService"/> 
     <endpoint address="json" 
        binding="webHttpBinding" 
        behaviorConfiguration="jsonBehavior" 
        contract="LiveAndesWCF.IUserService"/> 
     </service> 
     <service name="LiveAndesWCF.UserServiceRest" behaviorConfiguration="MetadataBehavior"> 
     <endpoint address="json" 
        behaviorConfiguration="WebBehavior" 
        binding="webHttpBinding" 
        contract="LiveAndesWCF.IUserServiceRest"/> 
     </service> 
     <service name="LiveAndesWCF.SightingServiceRest" behaviorConfiguration="MetadataBehavior"> 
     <endpoint address="soap" 
        binding="basicHttpBinding" 
        bindingConfiguration="soapBinding" 
        contract="LiveAndesWCF.ISightingServiceRest"/> 
     <endpoint address="json" 
        behaviorConfiguration="WebBehavior" 
        binding="webHttpBinding" 
        contract="LiveAndesWCF.ISightingServiceRest"/> 
     </service> 
     <service name="LiveAndesWCF.TestService"> 
     <endpoint address="soap" 
        binding="basicHttpBinding" 
        bindingConfiguration="soapBinding" 
        contract="LiveAndesWCF.ITestService"/> 
     <endpoint address="json" 
        binding="webHttpBinding" 
        behaviorConfiguration="jsonBehavior" 
        contract="LiveAndesWCF.ITestService"/> 
     </service> 
    </services> 


    <bindings> 
     <basicHttpBinding> 
     <binding name="soapBinding" maxReceivedMessageSize="99999999" closeTimeout="00:02:00" openTimeout="00:02:00" receiveTimeout="00:10:00" sendTimeout="00:02:00"> 
      <readerQuotas maxArrayLength="76384000" maxStringContentLength="2147483647"/> 
      <security mode="None"/> 
     </binding> 
     </basicHttpBinding> 
     <webHttpBinding> 
     <binding maxReceivedMessageSize="99999999" closeTimeout="00:02:00" openTimeout="00:02:00" receiveTimeout="00:10:00" sendTimeout="00:02:00"> 
      <readerQuotas maxArrayLength="76384000" maxStringContentLength="2147483647"/> 
     </binding> 
     </webHttpBinding> 
    </bindings> 


    <behaviors> 
     <endpointBehaviors> 
     <behavior name="jsonBehavior"> 
      <enableWebScript/> 
      <!--<webHttp/>--> 
     </behavior> 
     <behavior name="WebBehavior"> 
      <webHttp /> 
     </behavior> 
     </endpointBehaviors> 



     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpGetEnabled="true"/> 
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
     <behavior name="MetadataBehavior"> 
      <serviceMetadata httpGetEnabled="true" httpGetUrl="" /> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 
</configuration> 
+0

WP7可以使用JSON很容易,除非其已書面手機應用程序需要WCF –

+0

感謝德里克的答案我怎麼能這樣做是爲了使用JSON因爲當我嘗試使用!? slsvcutil工具只用json端點創建引用,它所說的只是「沒有與Silverlight 3兼容的端點」。請參閱此問題以瞭解wha我在說:http://stackoverflow.com/questions/7650509/bad-request-restsharp-windows-phone-7 –

回答

1

您可以這樣回答自己,然後將其標記爲答案或紀念這一個。

「因爲當我嘗試使用slsvcutil工具來創建只用JSON端點引用,所有它說是‘沒有終點的Silverlight 3’

兼容看到這個問題,知道我在說: Bad Request RestSharp Windows Phone 7