資源簡介
Web Service示例。不知道如何寫WEB service程序,那就認真看看這個實例吧!

代碼片段和文件信息
package?com.accp.client;
import?java.net.MalformedURLException;
import?java.util.Collection;
import?java.util.HashMap;
import?javax.xml.namespace.QName;
import?org.codehaus.xfire.XFireRuntimeException;
import?org.codehaus.xfire.aegis.AegisBindingProvider;
import?org.codehaus.xfire.annotations.AnnotationServiceFactory;
import?org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations;
import?org.codehaus.xfire.client.XFireProxyFactory;
import?org.codehaus.xfire.jaxb2.JaxbTypeRegistry;
import?org.codehaus.xfire.service.Endpoint;
import?org.codehaus.xfire.service.Service;
import?org.codehaus.xfire.soap.AbstractSoapBinding;
import?org.codehaus.xfire.transport.TransportManager;
public?class?BookServiceClient?{
????private?static?XFireProxyFactory?proxyFactory?=?new?XFireProxyFactory();
????private?HashMap?endpoints?=?new?HashMap();
????private?Service?service0;
????public?BookServiceClient()?{
????????create0();
????????Endpoint?BookServicePortTypeLocalEndpointEP?=?service0?.addEndpoint(new?QName(“http://xfire.accp.com“?“BookServicePortTypeLocalEndpoint“)?new?QName(“http://xfire.accp.com“?“BookServicePortTypeLocalBinding“)?“xfire.local://BookService“);
????????endpoints.put(new?QName(“http://xfire.accp.com“?“BookServicePortTypeLocalEndpoint“)?BookServicePortTypeLocalEndpointEP);
????????Endpoint?BookServiceHttpPortEP?=?service0?.addEndpoint(new?QName(“http://xfire.accp.com“?“BookServiceHttpPort“)?new?QName(“http://xfire.accp.com“?“BookServiceHttpBinding“)?“http://localhost:8080/xfire-server/services/BookService“);
????????endpoints.put(new?QName(“http://xfire.accp.com“?“BookServiceHttpPort“)?BookServiceHttpPortEP);
????}
????public?object?getEndpoint(Endpoint?endpoint)?{
????????try?{
????????????return?proxyFactory.create((endpoint).getBinding()?(endpoint).getUrl());
????????}?catch?(MalformedURLException?e)?{
????????????throw?new?XFireRuntimeException(“Invalid?URL“?e);
????????}
????}
????public?object?getEndpoint(QName?name)?{
????????Endpoint?endpoint?=?((Endpoint)?endpoints.get((name)));
????????if?((endpoint)?==?null)?{
????????????throw?new?IllegalStateException(“No?such?endpoint!“);
????????}
????????return?getEndpoint((endpoint));
????}
????public?Collection?getEndpoints()?{
????????return?endpoints.values();
????}
????private?void?create0()?{
????????TransportManager?tm?=?(org.codehaus.xfire.XFireFactory.newInstance().getXFire().getTransportManager());
????????HashMap?props?=?new?HashMap();
????????props.put(“annotations.allow.interface“?true);
????????AnnotationServiceFactory?asf?=?new?AnnotationServiceFactory(new?Jsr181WebAnnotations()?tm?new?AegisBindingProvider(new?JaxbTypeRegistry()));
????????asf.setBindingCreationEnabled(false);
????????service0?=?asf.create((com.accp.client.BookServicePortType.class)?props);
????????{
????????????AbstractSoapBinding?soapBinding?=?asf.createSoap11Binding(service0?new?QName(“http://xfire.accp.com“?“BookServicePort
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????645??2008-12-03?18:20??xfire-client\.classpath
?????文件????????309??2008-12-03?18:11??xfire-client\.myme
?????文件???????1014??2008-12-03?18:11??xfire-client\.project
?????文件???????4610??2008-12-03?18:20??xfire-client\src\com\accp\client\BookServiceClient.java
?????文件????????878??2008-12-03?18:20??xfire-client\src\com\accp\client\BookServicePortType.java
?????文件???????1467??2008-12-03?18:28??xfire-client\src\com\accp\test\BookTest.java
?????文件???????1464??2008-12-03?18:20??xfire-client\src\com\accp\xfire\AddBook.java
?????文件???????1229??2008-12-03?18:20??xfire-client\src\com\accp\xfire\AddBookResponse.java
?????文件???????1869??2008-12-03?18:20??xfire-client\src\com\accp\xfire\ArrayOfBook.java
?????文件???????4872??2008-12-03?18:20??xfire-client\src\com\accp\xfire\Book.java
?????文件????????748??2008-12-03?18:20??xfire-client\src\com\accp\xfire\GetAllBook.java
?????文件???????1528??2008-12-03?18:20??xfire-client\src\com\accp\xfire\GetAllBookResponse.java
?????文件???????3906??2008-12-03?18:20??xfire-client\src\com\accp\xfire\ob
?????文件????????168??2008-12-03?18:20??xfire-client\src\com\accp\xfire\package-info.java
?????文件?????????39??2008-12-03?18:11??xfire-client\WebRoot\me
?????文件???????5422??2008-12-03?18:20??xfire-client\WebRoot\WEB-INF\classes\com\accp\client\BookServiceClient.class
?????文件????????796??2008-12-03?18:20??xfire-client\WebRoot\WEB-INF\classes\com\accp\client\BookServicePortType.class
?????文件???????3032??2008-12-03?18:28??xfire-client\WebRoot\WEB-INF\classes\com\accp\test\BookTest.class
?????文件????????916??2008-12-03?18:20??xfire-client\WebRoot\WEB-INF\classes\com\accp\xfire\AddBook.class
?????文件????????797??2008-12-03?18:20??xfire-client\WebRoot\WEB-INF\classes\com\accp\xfire\AddBookResponse.class
?????文件????????962??2008-12-03?18:20??xfire-client\WebRoot\WEB-INF\classes\com\accp\xfire\ArrayOfBook.class
?????文件???????2171??2008-12-03?18:20??xfire-client\WebRoot\WEB-INF\classes\com\accp\xfire\Book.class
?????文件????????562??2008-12-03?18:20??xfire-client\WebRoot\WEB-INF\classes\com\accp\xfire\GetAllBook.class
?????文件????????981??2008-12-03?18:20??xfire-client\WebRoot\WEB-INF\classes\com\accp\xfire\GetAllBookResponse.class
?????文件???????2713??2008-12-03?18:20??xfire-client\WebRoot\WEB-INF\classes\com\accp\xfire\ob
?????文件????????321??2008-12-03?18:20??xfire-client\WebRoot\WEB-INF\classes\com\accp\xfire\package-info.class
?????文件????????288??2008-12-03?18:11??xfire-client\WebRoot\WEB-INF\web.xm
?????文件????????439??2008-12-03?16:56??xfire-server\.classpath
?????文件????????309??2008-12-03?16:56??xfire-server\.myme
?????文件???????1416??2008-12-03?17:20??xfire-server\.project
............此處省略50個文件信息
評論
共有 條評論