With Web Services External XML, use the web service as a data source, the content passed by the web service is XML, which will b

zhaozj2021-02-16  61

An intermediate layer implemented in a web service, providing a getCustomers method to retrieve data in the database, and supplied to the client with standard SOAP via HTTP. 1. Specific implementation (code only for reference) Intermediate Customer-Data.asmx Implementation Web Services <% @ WebService Language = "C #" Class = "Customer"%> Using System; Using System.Data; Using System.Web.Services ; // Import the Web Service Name Space Using System.Configuration;

[WebService (Description = "Customer Service", Namespace = "http://127.0.0.1/webservices/4923/customer")] public class CustomerOrders {[WebMethod] public DataSet GetCustomers (String strCustID, String strCustName) // Use [ WebMethod] Features indicate that the getCustomers method is available through the web service, and the public function that does not declares [WebMethod] feature is unavailable to the client through web services. {// Retrieve data according to customer ID or customer name and return to DataSet}} representation: (1) Use Web Services Behavior Components (WebServices.htc), use it for IE to process Web services. About WebServices.htc introduction and downloads can go to http://msdn.microsoft.com/workshop/author/webservice/webservice.asp

View Customer - SELECT CUSTOMER

(2) Declaring a global variable to save MSXML analysis instance, create an OpenWebService function Open Web Services Once WebService.htc behavior Insert the page, you can use it to access Web service var objxmldata; function openwebservice () {htcwservice.useservice "Customer-Data.asmxWSDL", "CustData"); // Use the behavior's UseService method to open the web service, do the user to add the server to the query string through the WSDL to make it, and provide a "friendly" Name "CustData will use it in the code to reference Web service var iCallid = htcwservice.custdata.callservice (DataLoaded," GetCustomers ",", "); // Specify the parameters required to specify the callService method: Event handler name , The method name of the call and the parameters of this method, in order to get all customers, 2 empty strings are used as parameters} function DataLoaded (ObjResult.Error) {// Check if the error var strordcode = ObjResult. errorDetail.code; var strErrorMsg = objResult.errorDetail.string; var strErrorRaw = objResult.errorDetail.raw;} else {// If there is no error, it returns the data into an instance of the MSXML parser try {objXMLData = new ActiveXObject ( 'MSXML2.FreeThreadedDOMDocument');} catch (e) {} if (objXMLData == null) {return;} objXMLData.onreadystatechange = changeFunction; objXMLData.validateOnParse = true; objXMLData.async = true; objXMLData.loadXML (objResult. Raw.xml); // Load SOA from Web Services P Document}}}} {// Check the ReadyState Value of the XML Analyzer // When the value is 4, it indicates that the load or complete error IF (Objxmldata.readyState == 4) {IF (Objxmldata.parseerror.errorData! = 0) // Load XML, error ELSE {// load completion}}}} (3) Find and display customer details: Users use the text search box to search customers without giving the server The return, regardless of how many searches are performed (in order to provide a higher and faster response and user interface). Function Dosearch (STRSORTORDER) {// Get user ID or user name, Strsortorder is a sort parameter // convert XML document and stores the transformation into a variable var strRRRESULT = GetStyledResult (strcustiD, strcustname, strsortorder); if (Strresult. Length> 0) {// Present StrResult} else {// Nothing Combined Data}}

function getStyledResult (strCustID, strCustName, strSortOrder) {// using XSLT stylesheets for transforming XML documents build XPath string // if (strCustID.length> 0) var strXPath = 'descendant :: Customers [starts-with (child :: CustomerID $ Custid)] 'Else Var strxpath =' Descendant :: Customers [Contains (Child :: CompanyName, $ CustName)] ';

// Create a style table code VAR strStyle = ' / N' ' / n ' ' / n ' ' / n ' ' / n ' '

/ n ' ' / n ' ' / n' '
/ n ' ' / n' ' / n ' ' city / n ' / n ' ' / n ' ' / n'

' / n' '

/ n ' ' / n ' ' / n ' ' / n ' ' / n ' / n' 'view-orders.aspx? Customerid = / n ' ' / n ' / n' ' / n' ' / n' ' / n' ' / n' ' / n' ' / N ' ' / N ' / n' '../../update-orders/ie5/Edit-ORDERS.ASPX 帖子 帖子 帖子 帖子 = / n ' ' / n ' ' edit orders / n ' ' / n ' '

转载请注明原文地址:https://www.9cbs.com/read-17957.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.048, SQL: 9