Xfire实现WebService · fei5156/java_component@27118a2 · GitHub
Skip to content

Commit 27118a2

Browse files
committed
Xfire实现WebService
1 parent 83bc0c9 commit 27118a2

6 files changed

Lines changed: 85 additions & 0 deletions

File tree

chapter9_1_xfire_server/pom.xml

Lines changed: 33 additions & 0 deletions
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.critc.xfire;
2+
3+
/**
4+
* Author 孔垂云
5+
* Date 2017/5/25.
6+
*/
7+
public interface FirstService {
8+
public String sayHello(String name);
9+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.critc.xfire;
2+
3+
/**
4+
* Author 孔垂云
5+
* Date 2017/5/25.
6+
*/
7+
public class FirstServiceImpl implements FirstService {
8+
9+
public String sayHello(String name) {
10+
return "hello:" + name;
11+
}
12+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.critc.xfire;
2+
3+
import org.codehaus.xfire.client.Client;
4+
5+
import java.net.URL;
6+
7+
/**
8+
* Author 孔垂云
9+
* Date 2017/5/25.
10+
*/
11+
public class TestXfire {
12+
13+
public static void main(String[] args) {
14+
try {
15+
Client client = new Client(new URL("http://localhost:8080/services/FirstService?wsdl"));
16+
Object[] results = client.invoke("sayHello", new Object[] { "张三" });
17+
System.out.println((String) results[0]);
18+
} catch (Exception e) {
19+
e.printStackTrace();
20+
}
21+
}
22+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<beans>
2+
<service xmlns="http://xfire.codehaus.org/config/1.0">
3+
<name>FirstService</name>
4+
<namespace>http://smallnest.googlepages.com/FirstService</namespace>
5+
<serviceClass>com.critc.xfire.FirstService</serviceClass>
6+
<implementationClass>com.critc.xfire.FirstServiceImpl</implementationClass>
7+
</service>
8+
</beans>

pom.xml

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)