sameer karjatkar
sameer karjatkar

Reputation: 2067

WCF POST/GET method with parameters does not return any value

i have deployed my wcf service(dot NET) on IIS. When I call the service for an API with one parameter it does not return anything . Interestingly this happens only if the the API I call has parameters . We are calling the webservice from a PHP file . And we give the link of PHP to the client(javascript).

Following is my web.config

    <!-- Service Endpoints -->
    <!-- Unless fully qualified, address is relative to base address supplied above -->
    <endpoint address="" binding="webHttpBinding" contract="WcfServiceLibrary1.IService1" behaviorConfiguration="Web">
      <!-- 
          Upon deployment, the following identity element should be removed or replaced to reflect the 
          identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
          automatically.
      -->
     </endpoint>
    <!-- Metadata Endpoints -->
    <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
    <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehaviour">
      <!-- To avoid disclosing metadata information, 
      set the values below to false before deployment -->
      <serviceMetadata httpGetEnabled="True" 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="Web">
      <webHttp/>
    </behavior>
  </endpointBehaviors>
</behaviors>   </system.serviceModel>
<system.webServer>
    <directoryBrowse enabled="true" />
</system.webServer> </configuration>

Following is the contact in my webservices

 [ServiceContract(Namespace = "http://xomw764dei.dsone.3ds.com/IPDWSRest/Service1.svc")]
        public interface IService1
        {
            [OperationContract]
            [WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/getData", ResponseFormat = WebMessageFormat.Xml, Method = "GET")]
            string GetData();

            [OperationContract]
            CompositeType GetDataUsingDataContract(CompositeType composite);

            [OperationContract]
            [FaultContract(typeof(ExceptionOnIPDWS))]
            [WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/getAllServerMachines{poolingServer}", ResponseFormat = WebMessageFormat.Xml, Method = "GET")]
            //pServerName getAllServerMachines(string poolingServer); 
            string getAllServerMachines(string poolingServer); 

            [OperationContract]
            [FaultContract(typeof(ExceptionOnIPDWS))]
            [WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/getServerUtil", ResponseFormat = WebMessageFormat.Xml)]
            Status getServerUtil(string poolingServer,string serverPID, ref string oCreateResult); 



            // TODO: Add your service operations here
        }

My php files look like this

<?php
$url = 'http://xomw764dei/IPDWSRest/Service1.svc/getData';
//$url = func_get_arg(0);
$callback = $_GET["callback"];

echo($callback . "(");
    echo(file_get_contents($url));
echo (")");
?>



<?php
$url = 'http://xomw764dei/IPDWSRest/Service1.svc/getAllServerMachines';
//$url = func_get_arg(0);
$callback = $_GET["callback"];

echo($callback . "(");
echo(file_get_contents($url . '/' . $_POST["poolingServer"]));
echo (")");
?>

Now the first call in the browser works well http://:1136/getData.php

But the second call does not return any data

http://:1136/ServerTools.php?poolingServer=thunderw7dei

Upvotes: 0

Views: 325

Answers (1)

Yanire Romero
Yanire Romero

Reputation: 482

UriTemplate should be like this:

[OperationContract]
        [FaultContract(typeof(ExceptionOnIPDWS))]
        [WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/getAllServerMachines/{poolingServer}", ResponseFormat = WebMessageFormat.Xml, Method = "GET")]
        //pServerName getAllServerMachines(string poolingServer); 
        string getAllServerMachines(string poolingServer); 

Upvotes: 1

Related Questions