---
title: "JAX-WS   JWS"
author: "adapterofcoms"
date: "2015-07-02T17:52:51Z"
tags: []
categories: ["Web前端"]
slug: "jax-ws-jws"
draft: false
lastmod: "2015-07-02T17:52:51Z"
id: 2223831
url: "https://adapterofcoms.iteye.com/blog/2223831"
---

e.g:

**@WebService**  
public interface **DemoService** 

**@WebService**(**targetNamespace**="com.kmerit.kdm.demoservice.service",  
**serviceName**="demoService",  
**endpointInterface** ="com.kmerit.kdm.demoservice.service.DemoService")  
@Service("demoWSService")  
public class **DemoServiceImpl** implements DemoService

 

服务的发布：  
Endpoint.publish("http://localhost:8888/ws/demoService",new **DemoServiceImpl()**);

服务的调用：  
WebService webService=c.getAnnotation(WebService.class);  
String namespaceUrl = webService.targetNamespace();                
QName qname = new QName(namespaceUrl,webService.serviceName());  
URL wsdl\_url = new URL(SERVICE\_URL\_PREFIX+webService.serviceName()+"?wsdl");             
Service srvc = Service.create(wsdl\_url , qname);                 
Object wsAgent=srvc.getPort(**endpointInterface** );  // IService client = service.getPort(IService.class);