2014-09-01 2 views
0

IIS에 내 wcf 서비스 (NET)가 배포되었습니다. 하나의 매개 변수로 API에 대한 서비스를 호출하면 아무 것도 반환하지 않습니다. 흥미롭게도 이것은 내가 호출하는 API에 매개 변수가있는 경우에만 발생합니다. 우리는 PHP 파일에서 webservice를 호출합니다. 그리고 우리는 클라이언트 (자바 스크립트)에 PHP의 링크를 제공합니다. 다음매개 변수가있는 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> 

다음 내 웹 서비스의 접촉이다

[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

답변

1

UriTemplate은 다음과 같이해야합니다 :

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