Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
配置在同一URI上侦听的WCF JSONP和SOAP端点_Wcf_Jsonp - Fatal编程技术网

配置在同一URI上侦听的WCF JSONP和SOAP端点

配置在同一URI上侦听的WCF JSONP和SOAP端点,wcf,jsonp,Wcf,Jsonp,I JSONP启用了我的WCF ServiceContract。客户端正在成功调用JSONP服务(OperationContract)。我有许多其他的OperationContract(使用相同的ServiceContract),我想使用basicHttpBinding(SOAP)端点(使用相同的URI)公开它们。我认为我的服务网络配置设置正确。在执行此操作时,我是否应该能够使用VS“AddServiceReference”对话框窗口添加服务引用(代理)?还是需要在codebehind中手动生成

I JSONP启用了我的WCF ServiceContract。客户端正在成功调用JSONP服务(OperationContract)。我有许多其他的OperationContract(使用相同的ServiceContract),我想使用basicHttpBinding(SOAP)端点(使用相同的URI)公开它们。我认为我的服务网络配置设置正确。在执行此操作时,我是否应该能够使用VS“AddServiceReference”对话框窗口添加服务引用(代理)?还是需要在codebehind中手动生成客户端代码?如果我需要手动操作,有人能提供一个例子吗?还是我的服务网络配置配置不正确?我使用以下命令调用JSONP服务:

非常感谢

<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
<behaviors>
  <endpointBehaviors>
    <behavior name="webHttpBehavior">
      <webHttp />
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="DefaultBehaviors">          
      <serviceMetadata httpGetEnabled="true" />          
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <webHttpBinding>
    <binding name="JSONPBinding" crossDomainScriptAccessEnabled="true" />
  </webHttpBinding>
  <basicHttpBinding>
    <binding name="SOAPBinding" />
  </basicHttpBinding>
</bindings>
<services>
  <service name="Flixsit.Services.FlixsitWebServices" behaviorConfiguration="DefaultBehaviors">
    <clear />
    <endpoint name="JSONPEndPoint" address="jsonp"
                                   binding="webHttpBinding"
                                   bindingConfiguration="JSONPBinding"
                                   contract="Flixsit.Services.IFlixsitWebServices"
                                   behaviorConfiguration="webHttpBehavior" />
    <endpoint name="HttpEndPoint"  address=""
                                   binding="basicHttpBinding"
                                   bindingConfiguration="SOAPBinding"
                                   contract="Flixsit.Services.IFlixsitWebServices" />
    <host>
      <baseAddresses>
        <add baseAddress="http://Flixsit:1000/FlixsitWebServices.svc" />
      </baseAddresses>
    </host>
  </service>
</services>    


经过一段时间的加工,我正在创建下面的ChannelFactory(在codebehind中)。服务现在在两个端点都公开

try
    {
        EndpointAddress address = new EndpointAddress("http://Flixsit:1000/FlixsitWebServices.svc");
        WSHttpBinding binding = new WSHttpBinding();
        ChannelFactory<IFlixsitWebServices> factory = new ChannelFactory<IFlixsitWebServices>(binding, address);
        IFlixsitWebServices channel = factory.CreateChannel();

        //call the service operation  
        var customer = channel.GetCustomers();

        GridView1.DataSource = customer;
        GridView1.DataBind();

        //close the channel
        ((ICommunicationObject)channel).Close();

        //close factory
        factory.Close();
    }
    catch (Exception ex)
    {
        //log ex;
    }
试试看
{
EndpointAddress地址=新的EndpointAddress(“http://Flixsit:1000/FlixsitWebServices.svc");
WSHttpBinding=新的WSHttpBinding();
ChannelFactory工厂=新的ChannelFactory(绑定,地址);
IFlixsitWebServices通道=factory.CreateChannel();
//调用服务操作
var customer=channel.GetCustomers();
GridView1.DataSource=客户;
GridView1.DataBind();
//关闭频道
((ICommunicationObject)通道).Close();
//关闭工厂
工厂关闭();
}
捕获(例外情况除外)
{
//log-ex;
}