001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.soap; 014 015import org.apache.juneau.*; 016import org.apache.juneau.annotation.*; 017import org.apache.juneau.serializer.*; 018import org.apache.juneau.xml.*; 019 020/** 021 * Serializes POJOs to HTTP responses as XML+SOAP. 022 * 023 * <h5 class='topic'>Media types</h5> 024 * 025 * Handles <c>Accept</c> types: <bc>text/xml+soap</bc> 026 * <p> 027 * Produces <c>Content-Type</c> types: <bc>text/xml+soap</bc> 028 * 029 * <h5 class='topic'>Description</h5> 030 * 031 * Essentially the same output as {@link XmlDocSerializer}, except wrapped in a standard SOAP envelope. 032 */ 033@ConfigurableContext 034public final class SoapXmlSerializer extends XmlSerializer { 035 036 //------------------------------------------------------------------------------------------------------------------- 037 // Configurable properties 038 //------------------------------------------------------------------------------------------------------------------- 039 040 static final String PREFIX = "SoapXmlSerializer"; 041 042 /** 043 * Configuration property: The <c>SOAPAction</c> HTTP header value to set on responses. 044 * 045 * <h5 class='section'>Property:</h5> 046 * <ul> 047 * <li><b>Name:</b> <js>"SoapXmlSerializer.SOAPAction.s"</js> 048 * <li><b>Data type:</b> <c>String</c> 049 * <li><b>Default:</b> <js>"http://www.w3.org/2003/05/soap-envelope"</js> 050 * <li><b>Methods:</b> 051 * <ul> 052 * <li class='jm'>{@link SoapXmlSerializerBuilder#soapAction(String)} 053 * </ul> 054 * </ul> 055 */ 056 public static final String SOAPXML_SOAPAction = PREFIX + ".SOAPAction.s"; 057 058 059 //------------------------------------------------------------------------------------------------------------------- 060 // Instance 061 //------------------------------------------------------------------------------------------------------------------- 062 063 final String soapAction; 064 065 /** 066 * Constructor. 067 * 068 * @param ps The property store containing all the settings for this object. 069 */ 070 public SoapXmlSerializer(PropertyStore ps) { 071 super(ps, "text/xml", "text/xml+soap"); 072 soapAction = getStringProperty(SOAPXML_SOAPAction, "http://www.w3.org/2003/05/soap-envelope"); 073 } 074 075 @Override /* Context */ 076 public SoapXmlSerializerBuilder builder() { 077 return new SoapXmlSerializerBuilder(getPropertyStore()); 078 } 079 080 /** 081 * Instantiates a new clean-slate {@link SoapXmlSerializerBuilder} object. 082 * 083 * <p> 084 * This is equivalent to simply calling <code><jk>new</jk> SoapXmlSerializerBuilder()</code>. 085 * 086 * <p> 087 * Note that this method creates a builder initialized to all default settings, whereas {@link #builder()} copies 088 * the settings of the object called on. 089 * 090 * @return A new {@link SoapXmlSerializerBuilder} object. 091 */ 092 public static SoapXmlSerializerBuilder create() { 093 return new SoapXmlSerializerBuilder(); 094 } 095 096 @Override /* Serializer */ 097 public SoapXmlSerializerSession createSession() { 098 return createSession(createDefaultSessionArgs()); 099 } 100 101 @Override /* Serializer */ 102 public SoapXmlSerializerSession createSession(SerializerSessionArgs args) { 103 return new SoapXmlSerializerSession(this, args); 104 } 105 106 //----------------------------------------------------------------------------------------------------------------- 107 // Properties 108 //----------------------------------------------------------------------------------------------------------------- 109 110 /** 111 * Configuration property: The SOAPAction HTTP header value to set on responses. 112 * 113 * @see #SOAPXML_SOAPAction 114 * @return 115 * The SOAPAction HTTP header value to set on responses. 116 */ 117 public String getSoapAction() { 118 return soapAction; 119 } 120 121 //----------------------------------------------------------------------------------------------------------------- 122 // Other methods 123 //----------------------------------------------------------------------------------------------------------------- 124 125 @Override /* Context */ 126 public ObjectMap toMap() { 127 return super.toMap() 128 .append("SoapXmlSerializer", new DefaultFilteringObjectMap() 129 .append("soapAction", soapAction) 130 ); 131 } 132}