0
JsonPリクエストを返すWCFサービスを構築したいとします。WCPリクエストからJsonPを返す方法は?
jsonpCallback({"fileNames": "IDR023.T.201705201412.png、IDR023.T.201705201418.png"});を返すようにします。
だから私は
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="BomService.BOM" behaviorConfiguration="ServiceBehaviour">
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address ="" binding="webHttpBinding" contract="BomService.IBOM" 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>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="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="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
のWebConfig
次WCFサービスにIBOM.cs
[ServiceContract]
public interface IBOM
{
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json)]
string GetData();
}
BOM.cs
public class BOM : IBOM
{
public string GetData()
{
return "jsonpCallback({\"fileNames\":\"IDR023.T.201705201412.png, IDR023.T.201705201418.png\"});";
}
}
を作成した。しかし、私は戻って取得しています"jsonpCallback({\" fileNames \ ":\" IDR023.T.201705201412.png、IDR023.T.201705201418.png \ "}));"
文字列を返して、必要なものを返すように設定しようとしています。これがJSONPにとって最善の方法ですか?または、私が興味を持っている人のため