2010-11-08 79 views
0

我是wcf的新手,下面是WCF WSDL返回的内容,我的问题是,如何从html页面调用WCF服务?如何使HTML文件的WCF调用?

<wsdl:definitions name="MyService" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"> 
    - <wsdl:types> 
    - <xsd:schema targetNamespace="http://tempuri.org/Imports"> 
     <xsd:import schemaLocation="http://..../tools/MyService.svc?xsd=xsd0" namespace="http://tempuri.org/" /> 
     <xsd:import schemaLocation="http://..../tools/MyService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" /> 
     <xsd:import schemaLocation="http://..../tools/MyService.svc?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/MyService" /> 
    </xsd:schema> 
    </wsdl:types> 

回答

0

像这样:

 $.ajax({ 
      url: "/tools/MyService.svc/Getist", 
      type: "GET", 
      context: document.body, 
      contentType: 'application/json; charset=utf-8', 
      datatype: 'json', 
      success: function (data) { 
       // do something 
      } 
     }); 

我不知道有关参数 - Getist之后他们会去的网址,但我不知道他们的名字 - 它们存储在/tools/MyService.svc? xsd = xsd0

1

您需要使用JavaScript库(如jQuery)向Web服务发出Ajax请求。我建议按照“jQuery WCF AJAX”的方式搜索谷歌,这应该会给你一些有用的例子。