⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index.html

📁 ajax 框价.是个好工具.javascript 矿家.可以用在任何平台.
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<pre><code>var lService = BiWebService();lService.useService("$BindowsCenterWsdl", "BindowsCenter");alert(lService.BindowsCenter.callService("GetLatestVersionId", "bindows"));</code></pre>This code will perform the same invocation as the former example.<br>Again, no actual JavaScript code definition of the web service methods is available to the developer.</li><li><strong>Additional methods</strong> allow specifying several aspects of the method invocation, such as whether it shouldbe synchronous or asynchronous.</li><li><strong>Using Wsdl2BiWs:</strong> Using this method, a <strong>stub class</strong> is automatically generated from the webservice WSDL <em class="underline">before runtime</em>. This class provides the API to access the service operationssynchronously or asynchronously. The stub implementation relies on the former invocation methods described above.<br>As opposed to the former invocation techniques, in this method JavaScript code describing the service API isactually generated and available to the developer.</li></ul><p>The rest of this guide focuses in using Wsdl2BiWs to access web services. To learn more about the othertechniques, please refer to the <!--LINK--><code>BiWebService</code> class documentation.</p><h3><a name="2.3"></a>2.3 Preparing to Develop a Web Service Client</h3><h4><a name="2.3.1"></a>2.3.1 Prerequisites</h4><p>In order to develop a web service client application using Wsdl2BiWs, you should have the following:</p><ul><li>A system capable of running Bindows&trade; applications, </li><li>An installed Python interpreter of version 2.3 or higher. This can be obtained at <a href="http://www.python.org">http://www.python.org</a>.</li><li>Knowledge of the service you want to access, and a WSDL file describing the service. While a WSDL isnecessary, it is usually not enough; supplementary documentation of the web service's exposed API shouldbe studied in order to gain complete understanding of its semantics.</li></ul><div class="SampleTrail"><p>For our Bindows&trade; Center sample application, the WSDL file can be obtained at<a href="http://www.bindows.net/BindowsCenter/BindowsCenter.asmx?WSDL">http://www.bindows.net/BindowsCenter/BindowsCenter.asmx?WSDL</a>.</p></div><h4><a name="2.3.2"></a>2.3.2 Installing and Running Wsdl2BiWs</h4><p>Wsdl2BiWs is installed with the Bindows&trade; framework. It resides in<code> &lt;bindows&gt;/util/Wsdl2BiWs </code> where <code> &lt;bindows&gt; </code> is the root path for theBindows&trade; installation.In order to run Wsdl2BiWs, we invoke the Python interpreter to execute file <code>Wsdl2BiWs.py</code> in the Wsdl2BiWs directory. On a Windows PC with Bindows&trade; installed to <code>c:\bindows</code>, we issue the following command: </p><p class="CmdTranscript"><code>c:\bindows\util\Wsdl2BiWs>Wsdl2BiWs.py</code> <strong>[command line arguments]</strong></p>It is recommended to add the path where <code>Wsdl2BiWs.py</code> resides to your system's search path. By not specifying any command line arguments, we can ask Wsdl2BiWs to display a help screen:<p class="CmdTranscript"><code>c:\bindows\util\Wsdl2BiWs&gt;Wsdl2BiWs.py</code></p><p> This command can be used to verify that the system is configured properly to run Wsdl2BiWs. A complete list ofvalid command line arguments is also provided in section <a href="#3.1">3.1</a>.</p><div class="SampleTrail"><p>For our Bindows&trade; Center sample application development stages, we assume that Wsdl2BiWs.py residesin your system's search path, and don't specify it's complete path to run. Also, we assume that Bindows&trade; resides in <code>c:\bindows</code>.</p></div><h3><a name="2.4"></a>2.4 Generating Code Using Wsdl2BiWs</h3><h4><a name="2.4.1"></a>2.4.1 Generating the Web Service Stub</h4><p>After having installed Bindows&trade; and Wsdl2BiWs, and studying the web service to which access isdesired, we can move on to generate the web service stub using Wsdl2BiWs. This stub will later be used toinvoke operations on the web service.</p><p>In order to generate the stub, we simply launch Wsdl2BiWs and specify, as a command line argument, a URLfor a WSDL to use for stub generation:</p><p class="CmdTranscript"><code>Wsdl2BiWs.py </code><strong>wsdl-url</strong></p><p>Notice that if you want Wsdl2BiWs to use a WSDL file located in your filesystem, you can use a URL ofthe form <code>file:</code><strong>[path]</strong>. For example, to build a stub based on file<code>c:\temp\sample.wsdl</code>, you should issue:</p><p class="CmdTranscript"><code>Wsdl2BiWs.py file:c:\temp\sample.wsdl</code></p><p>By default, the generated stub will reside in a JavaScript file named as the last path component inthe URL, excluding its suffixes. For example, for the URL <code>file:c:\temp\sample.wsdl</code>, the stubwill be generated to <code>sample.js</code> in the current directory. You can override this name byspecifying the <code><strong>-o</strong></code><strong>[filename]</strong> or <code><strong>--out=</strong></code><strong>[filename]</strong>command line options. So, to output the stub for <code>c:\temp\sample.wsdl</code> into file<code>c:\stubs\SampleStub.js</code>, you should issue the following command:</p><p class="CmdTranscript"><code>Wsdl2BiWs.py --out=c:\stubs\SampleStub.js file:c:\temp\sample.wsdl</code></p><p>Wsdl2BiWs will generate a stub class for each service in the supplied WSDL. Each class will a pair ofmethods corresponding to each of the service's methods -- one for asynchronous invocation and anotherfor synchronous invocation. The exact structure and naming of stub classes is described in<a href="#3.2">3.2</a>. You can restrict the set of classes and methods generated by the stub, if youonly require some of them. </p><p>To generate only some of the service in the WSDL file, use the<code><strong>-s</strong></code><strong>[service name]</strong> or <code><strong>--service=</strong></code><strong>[service name]</strong>command-line options. You can specify multiple instances of these options, one for each desired service.The specified service name should be of the form<code>[</code><strong>[namespace-uri]</strong><code>]</code><strong>[service-name]</strong>where <strong>[namespace-uri]</strong> represents the URI of the target namespace in which the service name isdefined, and <strong>[service-name]</strong> is the service's name -- as specified in the WSDL file.</p><p>To control which methods are generated for each of the generated service's operations, use the<code><strong>-t</strong></code><strong>[calltype]</strong> or <code><strong>--calltype</strong></code><strong>[calltype]</strong> options --where <strong>[calltype]</strong> can be one of the following:</p><table border="solid"><thead>   <tr><th><strong>[calltype]</strong> Value</th><th>Genrated code</th></tr></thead><tbody>   <tr>     <td><code>async</code></td>     <td>Generate methods for asynchronous invocation of service operations only.</td>  </tr>   <tr>     <td><code>sync</code></td>     <td>Generate methods for synchronous invocation of service operations only.</td>  </tr>   <tr>     <td><code>both</code></td>     <td>Generate methods for both asynchronous and synchronous invocation of service operations.</td>  </tr></tbody></table><p>For example, to generate only synchronous calls for the <code>Sample</code> service defined in the<code>http://tempuri.org/</code> namespace, based our WSDL file residing at<code>c:\temp\sample.wsdl</code>, the following command should be issued:</p><p class="CmdTranscript"><code>Wsdl2BiWs.py --service=[http://tempuri.org/]Sample -tsync file:c:\temp\sample.wsdl</code></p><h4><a name="2.4.2"></a>2.4.2 Generating the Web Service Test Client</h4><p>In addition to the web service stub itself, Wsdl2BiWs also allows you to generate a sample applicationusing the stub, which can serve two purposes:</p><ul><li>Demonstrate how to write application code utilizing the stub, and</li><li>Experiment with the accessed web service by invoking its operations and examining their return values.</li></ul><p>You can instruct Wsdl2BiWs to generate the sample application by including the <code><strong>-a</strong></code><strong>[filename]</strong>or <code><strong>--app=</strong></code><strong>[filename]</strong> command line options, where <strong>[filename]</strong> is the name of the file(including path) into which the JavaScript code for the sample application will be generated.<strong>For this version, the file must reside in the same directory as the stub.</strong> Wsdl2BiWs will fail if this is not met.</p><p>The sample application consists of three files:</p><ul><li>The JavaScript file specified to the <code><strong>-a</strong></code> or <code><strong>-app=</strong></code> option, containingthe test client applcation code,</li><li>An ADF file for the application -- linking the test client code and the web service stub; this file is namedas the JavaScript file name, replacing its <code>.js</code> suffix with <code>.xml</code>, and<li>An HTML file used to launch the application; this file is named as the JavaScript file name,replacing its <code>.js</code> suffix with <code>.html</code></li></ul><p>The following command will instruct Wsdl2BiWs to generate a web service stub to interact with all services defined inWSDL file <code>c:\temp\sample.wsdl</code> into file <code>c:\stubs\SampleStub.js</code>, and generate a test clientfor this stub into file <code>c:\stubs\TestSampleStub.js</code>. Once code generation is complete, Wsdl2BiWs will launchthe test client in a browser.</p><p class="CmdTranscript"><code>Wsdl2BiWs.py --out=c:\stubs\SampleStub.js --app=c:\stubs\TestSampleStub.js file:c:\temp\sample.wsdl</code></p><p>If you don't want Wsdl2BiWs to automatically launch the test client once generation is complete, you can specify the<code><strong>--nolaunch</strong></code> command line option, as the following sample demonstrates:</p><p class="CmdTranscript"><code>Wsdl2BiWs.py --out=c:\stubs\SampleStub.js --app=c:\stubs\TestSampleStub.js --nolaunch file:c:\temp\sample.wsdl</code></p><p>You can then launch the test client at your will by openning its launcher HTML file (in this case,<code>c:\stubs\TestSampleStub.html</code>) in a web browser.</p><p>Normally, the generated sample application will use the Bindows&trade; installation from which Wsdl2BiWs was invoked.In order to generate the application such that it uses a different Bindows&trade; installation, use the<code><strong>-b</strong></code><strong>[bindowsdir]</strong> or <code><strong>--bindows=</strong></code><strong>[bindowsdir]</strong> options, where<strong>[bindowsdir]</strong> is the required Bindows&trade; version's root installation directory. The following exampledemonstrates the use of this option. It will generate a stub for all services defined in WSDL file<code>c:\temp\sample.wsdl</code> into file <code>c:\stubs\SampleStub.js</code>, and a stub test client into file<code>c:\stubs\TestSampleStub.js</code>. The stub test client will use the bindows installation rooted at<code>c:\bindows11</code> regardless of the installation from which Wsdl2BiWs was launched. Once code generation iscomplete, the generated test application will be launched.</p><p class="CmdTranscript"><code>Wsdl2BiWs.py --out=c:\stubs\SampleStub.js --app=c:\stubs\TestSampleStub.js --bindows=c:\bindows11file:c:\temp\sample.wsdl</code></p><div class="SampleTrail"><p>For the Bindows&trade; Center sample application, we want to generate a stub based on the service'sWSDL. The exact service we're interested in is the <code>BindowsCenter</code> service, defined in namespace<code>http://www.bindows.net/ws/BindowsCenter/</code>. We want both synchronous and asynchronous methodsto be generated, which is the default. We will generate the stub to a file named <code>BCService.js</code> inour sample application directory.</p><p>In addition, we would like a test client to be generated -- so that we can experiment with the Bindows&trade; Centerweb service before writing the acutal client application. We will generate the test client to a file named<code>BCServiceTester.js</code> in our sample application directory. We don't want to launch this sampleapplication just yet.</p><p>To complete this step, we will issue the following command:</p><p class="CmdTranscript"><code>Wsdl2BiWs.py --service=[http://www.bindows.net/ws/BindowsCenter/]BindowsCenter -oc:\bindows\samples\BindowsCenter\BCService.js --app=c:\bindows\samples\BindowsCenter\BCServiceTester.js $BindowsCenterWsdl --nolaunch</code></p><p>We can now open file <code>c:\bindows\samples\BindowsCenter\BCServiceTester.html</code> in a web browser to test ourstub -- which we will do in the next step.</p></div><h3><a name="2.5"></a>2.5 Testing the Web Service Stub</h3><p>Before starting to write down the complete web service client application, it is recommended that youtest the stub generated using a test client. Section <a href="#2.4.2">2.4.2</a> discussed how a test client can begenerated using Wsdl2BiWs. This section describes how this test client can be operated to experiment with the accessedweb service.</p><p>Once the test client application is launched as described in section <a href="#2.4.2">2.4.2</a>, its UIwill be presented. The test client application's UI consists of four main parts: the information area,the services list, and the service port tabs. An annotated version of a test client application's UI is

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -