在从范例中作出选择之后,范例会以一种相似的方式作出另外一个请求(清单4),尽管这次预期的响应是一个服务描述文件。
After a selection is made from the sample, the sample makes another request (Listing 4) in a similar way, although this time the expected response is a service description document.
服务器应该用一个服务文档来响应这个请求,其中列出了客户机可用的集合,如清单3所示。
The server should respond with a service document that enumerates the collections available to the client as illustrated in Listing 3.
一个有关路由器接收所有来源于服务接口的请求的实例(见下面的清单4)。
An instance of the router receives all requests coming through the service interface (see Listing 4 below).
首先,看一下清单1中的XML,您必须手工进行编码以发送一个SOAP请求来寻找提供服务的企业。
First off, take a look at the XML in Listing 1, which you would have to handcode to send a SOAP request to find a business offering services.
清单8:通过语义请求ESRI的地址查询Web服务调用过程。
Listing 8: Invocation process of ESRI's Address Finder Web Service through semantic request.
如清单5中所示,脚本只是启用了ipvsadm服务,然后实际上使用了相同的代码节以便将Web和SSL请求转发给每个单个的realserver。
As you can see in Listing 5, the script simply enables the ipvsadm services, then has virtually identical stanzas to forward Web and SSL requests to each of the individual realservers.
清单9:调用ESRI的地址查询Web服务的语义请求。
Listing 9: Semantic request for invoking ESRI's Address Finder Web service.
此客户端用于初始化y QLWeb服务端点的未验证的GET请求,如之前在清单1中所做的。
This client is used to initialize an unauthenticated GET request for the YQL web service endpoint, as was done earlier in Listing 1.
清单3显示了Web服务使用DOMFaultListener对格式不正确的请求做出的SOAP响应。
Listing 3 shows the web service's SOAP response to a malformed request using DOMFaultListener.
另一个变更是更新对Account .create的调用,以在Web服务请求中包含country字段,如清单6中所示。
The other change is updating the call to Account.create to include the country field on the Web service request, as shown in Listing 6.
清单1展示了一个对服务的示例请求,以及随后的响应(为适应页面宽度重新调整了格式)。
Listing 1 shows a sample request to the service, followed by the response (reformatted to fit the page width).
其中,最重要的是,语义请求和响应可以隐式调用Web服务的实现细节,如清单10 和 11 所示。
Meanwhile, and most importantly, semantic request and response can hide the implementation details for invoking the Web services, as shown in Listings 10 and 11.
清单11:调用ESRI的地址请求Web服务之后的语义响应。
Listing 11: Semantic response after invoking ESRI's Address Finder Web service.
另有一个文件 WEB-INF/sun-jaxws.xml(清单2所示)用于配置Metro,使其将servlet接收的请求路由到服务实现代码。
A separate file, WEB-INF/sun-jaxws.xml (shown in Listing 2), is used to configure Metro to route requests received by the servlet to the service-implementation code.
虽然清单13中的代码看起来似乎不错,但是还有一个问题——如果服务器响应请求并完成了处理但是报告了一个错误怎么办?
Despite the apparent success of the code in Listing 13, there's still a problem — what if the server responds to your request and finishes processing, but reports an error?
如果您在服务器运行时尝试将此请求发送给服务器,则得到的结果可能会出乎您的预料(见清单5)。
If you try to send this request to the server as it stands, the result might not be what you expect (see Listing 5).
通过语义响应,如清单11所示,服务请求者可以忽略这些实现细节使得实现更加紧凑高效。
Through semantic response, as described in Listing 11, service requesters can ignore all such implementation details to make the implementation more compact and efficient.
为了确保服务器不但完成了一个请求,而且还报告了一个OK状态,请在您的回调函数中添加另外一个检查功能,如 清单7 所示。
To make sure that not only did the server finish with a request but that it also reported an OK status, add an additional check in your callback function as shown in Listing 7.
清单2显示当应用服务器接收客户机HTTP请求时发生的情况。
Listing 2 shows what happens in the application server when it receives the clients HTTP request.
现在,再回到清单4,注意到为了向服务器进行异步回调,您必须要知道这个请求的URL。
Refer back to Listing 4 now and note that to make an asynchronous callback to the server, you have to know the URL to request.
清单1中的代码从服务器请求一个页面然后将内容放入页面主体的标记中。
The code in Listing 1 requests a page from the server, and then places that content into a tag in the body of the page.
由于现在已经从服务器接收完数据,请求就完成了,可以关闭网络活动指示器了,如清单4所示。
Because you are done receiving data from the server at this point, your request is complete and you can turn off the network activity indicator, as listing 4 demonstrates.
清单7显示发送给(POST)服务器的请求字符串。
Listing 7 shows the request string then being sent (POST) to the server.
清单4显示请求格式、RESTURL模式、以及服务器对请求的响应。
Listing 4 shows the request format, the REST URL pattern, and the server response to the request.
清单8显示了此代码更改,并给出了发送到服务器进行添加请求的XML以及检索书籍时从服务器返回的XML。
Listing 8 shows this code change along with the XML that was sent to the server for the add request, and the XML that returned from the server when the books were retrieved.
CreateCoordinationContext请求从应用程序被发送到激活服务,如清单14所示。
The CreateCoordinationContext request is sent from application to the Activation Service as shown in Listing 14.
CreateCoordinationContext请求从应用程序被发送到激活服务,如清单12所示。
The CreateCoordinationContext request is sent from application to the Activation Service as shown in Listing 12.
同样,当一个SOAP请求被发送到Web服务并导致服务器抛出一个InvalidServerDataException 异常时,清单9中的 SOAP响应将被客户机接收。
Similarly, when a SOAP request is sent to a web service and causes the server throw an InvalidServerDataException, the SOAP response in Listing 9 is received by the client.
清单1包含的策略信息要求在客户机发送给服务器的请求中有usernametoken。
Listing 1 includes policy information to require UsernameToken on requests from the client to the server.
CreateCoordinationContext请求从应用程序被发送到激活服务,如清单1所示。
The CreateCoordinationContext request is sent from application to the Activation Service as shown in Listing 1.
应用推荐