简体   繁体   中英

WCF Service: Bad Request at only one function

I have programmed a WCF web service that works fine running in my 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. After some changes in my web.config, I got my service in a running state and calling functions works fine as well. 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.

Now my problem ( ;) sorry for 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.

I suppose it's something in my web.config but I really don't know what to change. 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. just for troubleshooting, try changing the uritemplate to something like UriTemplate:="User5/Get5/.."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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