V. JAX-WS Detailed Introduction

Source: Internet
Author: User
Tags wsdl

1. Common Packaging styles
1.1. Based on wrapper and document

1.2, based on bare

1.3. RPC-based

2. JAX-WS Common operation
2.1. Exception Handling

Creating Exception Handling Classes

The exception object is best exception object rather than RuntimeException

Adding messages and element in the WSDL

Set exceptions for porttype and binding

PortType shows that those methods throw exceptions.

Binding description of the encoding that throws the exception

2.2. Simple permission control

1. Create Header Element

2. Create message and BIND messages

3. Handling Message Headers

There are several ways to do this:

1, through the Saaj (directly create Soapbody and SoapHeader objects, through the dispatcher delivery message): Client: Can handle, server side currently no method to get SoapMessage

2, using Soaphandler treatment (Soapmessagecontext)

3, based on the Jaxws-ri method

Headers.create (Element): You can convert an element of a DOM to a header element

Client

Server-Side Authoring

4. Server-Side processing header

Server-Side Authoring

3_1, resolving package conflict issues

When there was Jax Ri would throw

Javax.xml.ws.soap.SOAPFaultException:javax.xml.ws.WebFault.messageName () ljava/lang/string;

This is because the Webfault object is used in the Jaxri, but the JDK also provides this method, which is called to invoke the JDK's webfault at this point, the MessageName method is not found

Solution: Copy the package Jax-ri.jar to the Endored folder in Lib in the JDK's JRE

3. Publish the service in Tomcat
3.1. Copy the WSDL folder into the Web-inf

3.1. Import Jax-ri Package

Jaxws-ri Reference Implements

3.2. Create a sun-jaxws.xml under Web-inf

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

<endpoints xmlns="Http://java.sun.com/xml/ns/jax-ws/ri/runtime" Version ="2.0">

< endpoint name ="MyService"

implementation= " org.konghao.service.MyServiceImpl" url-pattern= "/tc"/>

</endpo

Ints>

3.3. Configure Web. xml

<listener >

< Listener-class>com.sun.xml.ws.transport.http.servlet.wsservletcontextlistener </listener-class>

</listener>

< servlet>

< Servlet-name>myservice </servlet-name>

< Servlet-class>com.sun.xml.ws.transport.http.servlet.wsservlet </servlet-class>

</servlet>

< servlet-mapping>

< Servlet-name>myservice </servlet-name>

< url-pattern>/TC</url-pattern>

</servlet-mapping>

4. Binary processing
4.1, based on the first processing mode of MTOM

Special Note: Mtom can only be used on the server and cannot be passed mtom in the default jetty server

V. JAX-WS Detailed Introduction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.