0
我已經在IIS上部署了我的wcf服務(dot NET)。當我使用一個參數調用API的服務時,它不會返回任何內容。有趣的是,只有當我調用的API有參數時纔會發生這種情況。我們從一個PHP文件調用webservice。我們將PHP的鏈接提供給客戶端(javascript)。帶參數的WCF POST/GET方法不返回任何值
以下是我的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>
以下是我的web服務接觸
[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
}
我的PHP文件看起來像這樣
<?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 (")");
?>
現在在瀏覽器中第一次調用效果很好 的http://:1136 /訪問getdata.php
但是第二次通話不會返回任何數據
HTTP://:1136/ServerTools.php poolingServer = thunderw7dei