简体   繁体   English

WCF服务:仅一项功能的错误请求

[英]WCF Service: Bad Request at only one function

I have programmed a WCF web service that works fine running in my IDE. 我已经编程了一个WCF Web服务,该服务可以在我的IDE中正常运行。 Now I have built a setup and installed it on our web server and got some issues due to the configured HTTP to HTTPS redirect. 现在,我已经建立了一个设置并将其安装在我们的Web服务器上,由于配置了HTTP到HTTPS重定向,因此出现了一些问题。 After some changes in my web.config, I got my service in a running state and calling functions works fine as well. 在对web.config进行一些更改之后,我使我的服务处于运行状态,并且调用函数也正常工作。 For example, /Customers/GetAll returns a list of customer objects, serialized in JSON, it's the same for /Customer/name=XYZ that returns an object depending on the name of the customer. 例如,/ Customers / GetAll返回以JSON序列化的客户对象列表,对于/ Customer / name = XYZ来说,该列表相同,后者根据客户的名称返回对象。

Now my problem ( ;) sorry for VB.Net): 现在我的问题(;)为VB.Net感到抱歉):

   <OperationContract()> _
   <WebGet(ResponseFormat:=WebMessageFormat.Json, UriTemplate:="User/Get/value={pValue}&identifier={pSearchIdentifier}")> _
   Function GetUser(ByVal pValue As String, pSearchIdentifier As String) As LMEngine.User

returns only "Bad Request" and nothing else. 仅返回“错误请求”,而不会返回其他任何内容。 I also added some logging lines to this function. 我还向该函数添加了一些日志记录行。 If I run the service locally, all my log lines will be written in my file - on our web server, nothing happens. 如果我在本地运行该服务,我的所有日​​志行都会写入我的文件中-在我们的Web服务器上,什么也没有发生。

I suppose it's something in my web.config but I really don't know what to change. 我想这是我的web.config中的内容,但我真的不知道要更改什么。 May you please check the config for any errors? 您可以检查配置是否有任何错误?

  <system.serviceModel>
      <services>
         <service behaviorConfiguration="LogMeWebServiceRest.Service1Behavior" name="LogMeWebServiceRest.LogMe">
            <!--WCF Test Client-->
            <!--<endpoint address="" binding="wsHttpBinding" contract="LogMeWebServiceRest.ILogMe">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>-->
            <!-- For testing in Browser -->
            <endpoint address="" binding="webHttpBinding" contract="LogMeWebServiceRest.ILogMe" bindingConfiguration="LogMeEndpointBinding" behaviorConfiguration="webBehavior" />
         </service>
      </services>
      <bindings>
         <webHttpBinding>
            <binding name="LogMeEndpointBinding">
               <security mode="Transport">
               </security>
            </binding>
         </webHttpBinding>
      </bindings>
      <behaviors>
         <serviceBehaviors>
            <behavior name="LogMeWebServiceRest.Service1Behavior">
               <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
               <serviceMetadata httpsGetEnabled="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>
         </serviceBehaviors>
         <endpointBehaviors>
            <behavior name="webBehavior">
               <webHttp/>
            </behavior>
         </endpointBehaviors>
      </behaviors>
   </system.serviceModel>

Thank you! 谢谢!

This might be related to the url. 这可能与网址有关。 In webserver, may be it is calling different method, that is why it is not logging anything. 在Web服务器中,可能是正在调用不同的方法,这就是为什么它未记录任何内容。 just for troubleshooting, try changing the uritemplate to something like UriTemplate:="User5/Get5/.." 仅用于故障排除,请尝试将uritemplate更改为UriTemplate:=“ User5 / Get5 / ..”。

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

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