Java WebService记

本文介绍了如何使用Java和Apache CXF创建和消费Web服务。详细展示了从设置服务接口到发布服务,再到客户端调用的完整流程,并提到了Spring框架下与CXF的集成。
摘要由CSDN通过智能技术生成

import org.apache.axis2.client.Options;

import org.apache.axis2.rpc.client.RPCServiceClient;

public class WebServiceClient {

public static void main(String[] args) throws Exception {

RPCServiceClient serviceClient = new RPCServiceClient();

Options options = serviceClient.getOptions();

EndpointReference targetEPR = new EndpointReference(“http://192.168.0.105:8080/Axis2Demo_war_exploded/services/HelloService”);

options.setTo(targetEPR);

Object[] entryArgs = new Object[]{4, 2};

QName qName = new QName(“http://ws.apache.org/axis2”, “add”);

Object result = serviceClient.invokeBlocking(qName, entryArgs, new Class[]{int.class})[0];

qName = new QName(“http://ws.apache.org/axis2”, “send”);

serviceClient.invokeRobust(qName, new Object[]{“hello world!”});

}

}

Soap UI

Java WebService记

Java WebService记

Apache CXF

==========

Apache CXF是一个开源的、全功能的,容易使用的Web服务框架。CXF是两个项目的结合:由IONA技术公司开发的Celtix和由Codehaus主持的团队开发的XFire。

CXF支持的特性非常广泛,但特性主要在以下一些方面:

  • 支持的Web服务标准包括: SOAP WS-Addressing WS-Policy WS-ReliableMessaging WS-Security WS-SecurityPolicy WS-SecureConversation

  • JAS-WS API,用于Web服务开发 WSDL优先支持工具 Java优先支持

  • JAX-RS(JSR 311 1.0)API,用于RESTful Web服务开发

⬆️内容摘自Wiki百科。

发布服务

====

使用 Maven 构建项目,POM文件内容如下:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns=“http://maven.apache.org/POM/4.0.0”

xmlns:xsi=“http://www.w3.org/2001/XMLSchema-inst

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值