您好,登錄后才能下訂單哦!
本篇內(nèi)容介紹了“xfire如何實(shí)現(xiàn)webservice”的有關(guān)知識(shí),在實(shí)際案例的操作過(guò)程中,不少人都會(huì)遇到這樣的困境,接下來(lái)就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
第一步:導(dǎo)入所需jar包 下載地址:http://download.csdn.net/detail/qq_36291682/9714751
activation-1.1.jar
bcprov-jdk15-133.jar
commons-attributes-api-2.1.jar
commons-beanutils-1.7.0.jar
commons-codec-1.3.jar
commons-discovery-0.2.jar
commons-httpclient-3.0.jar
commons-logging-1.0.4.jar
jaxb-api-2.0.jar
jaxb-impl-2.0.1.jar
jaxb-xjc-2.0.1.jar
jaxen-1.1-beta-9.jar
jaxws-api-2.0.jar
jdom-1.0.jar
jetty-6.1.2rc0.jar
jetty-util-6.1.2rc0.jar
jmock-1.0.1.jar
jsr173_api-1.0.jar
junit-3.8.1.jar
mail-1.4.jar
opensaml-1.0.1.jar
saaj-api-1.3.jar
saaj-impl-1.3.jar
servlet-api-2.3.jar
servlet-api-2.5-6.1.2rc0.jar
spring-1.2.6.jar
stax-api-1.0.1.jar
stax-utils-20040917.jar
wsdl4j-1.6.1.jar
wss4j-1.5.1.jar
wstx-asl-3.2.0.jar
xbean-2.2.0.jar
xbean-spring-2.8.jar
xercesImpl-2.6.2.jar
xfire-all-1.2.6.jar
xfire-jsr181-api-1.0-M1.jar
xml-apis-1.0.b2.jar
XmlSchema-1.1.jar
xmlsec-1.3.0.jar
第二步:接口類
package xfire;
public interface IsayHello {
public abstract String sayHehe(String param);
}
第二步:接口實(shí)現(xiàn)
package xfire;
public class SayHelloImpl implements IsayHello {
@Override
public String sayHehe(String param) {
System.out.println("說(shuō):"+param);
return "說(shuō):"+param;
}
}
第三步:客戶端調(diào)用
package xfire;
import java.net.MalformedURLException;
import org.codehaus.xfire.XFire;
import org.codehaus.xfire.XFireFactory;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
public class client {
public static void main(String[] args) throws MalformedURLException {
XFire xfire = XFireFactory.newInstance().getXFire();
Service serviceModel = new ObjectServiceFactory().create(IsayHello.class);
IsayHello service = (IsayHello)new XFireProxyFactory(xfire).create(serviceModel, "http://localhost:9999/webService/services/Banking");
String string= service.sayHehe("哈哈");
System.out.println(string);
}
}
第四步:配置web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>XFireServlet</servlet-name>
<servlet-class>org.codehaus.xfire.transport.http.XFireConfigurableServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>XFireServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
</web-app>
第五步:在WEB-INF下邊新建文件夾META-INF 在META-INF下新建文件夾xfire 在xfire下新建文件services.xml 內(nèi)容如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xfire.codehaus.org/config/1.0">
<service>
<name>Banking</name>
<namespace>mybank</namespace>
<serviceClass>
xfire.IsayHello
</serviceClass>
<implementationClass>
xfire.SayHelloImpl
</implementationClass>
</service>
</beans>http://www.fuke029.com
“xfire如何實(shí)現(xiàn)webservice”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注億速云網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。