View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2010 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
10   *  See the GNU Lesser General Public License for more details at gnu.org.
11   */
12  
13  package com.eviware.soapui.impl.wsdl.support.soap;
14  
15  import java.io.IOException;
16  import java.util.List;
17  
18  import javax.xml.namespace.QName;
19  
20  import org.apache.xmlbeans.SchemaType;
21  import org.apache.xmlbeans.XmlError;
22  import org.apache.xmlbeans.XmlException;
23  import org.apache.xmlbeans.XmlObject;
24  import org.apache.xmlbeans.XmlValidationError;
25  
26  import com.eviware.soapui.support.StringUtils;
27  
28  /***
29   * Public behaviour for a SOAP Version
30   * 
31   * @author ole.matzura
32   */
33  
34  public interface SoapVersion
35  {
36  	public static final SoapVersion11 Soap11 = SoapVersion11.instance;
37  	public static final SoapVersion12 Soap12 = SoapVersion12.instance;
38  
39  	public QName getEnvelopeQName();
40  
41  	public QName getBodyQName();
42  
43  	public QName getHeaderQName();
44  
45  	public void validateSoapEnvelope( String soapMessage, List<XmlError> errors );
46  
47  	public String getContentTypeHttpHeader( String encoding, String soapAction );
48  
49  	public String getEnvelopeNamespace();
50  
51  	public String getFaultDetailNamespace();
52  
53  	public String getEncodingNamespace();
54  
55  	public XmlObject getSoapEncodingSchema() throws XmlException, IOException;
56  
57  	public XmlObject getSoapEnvelopeSchema() throws XmlException, IOException;
58  
59  	/***
60  	 * Checks if the specified validation error should be ignored for a message
61  	 * with this SOAP version. (The SOAP-spec may allow some constructions not
62  	 * allowed by the corresponding XML-Schema)
63  	 */
64  
65  	public boolean shouldIgnore( XmlValidationError xmlError );
66  
67  	public String getContentType();
68  
69  	public SchemaType getEnvelopeType();
70  
71  	public SchemaType getFaultType();
72  
73  	public String getName();
74  
75  	/***
76  	 * Utilities
77  	 * 
78  	 * @author ole.matzura
79  	 */
80  
81  	public static class Utils
82  	{
83  		public static SoapVersion getSoapVersionForContentType( String contentType, SoapVersion def )
84  		{
85  			if( StringUtils.isNullOrEmpty( contentType ) )
86  				return def;
87  
88  			SoapVersion soapVersion = contentType.startsWith( SoapVersion.Soap11.getContentType() ) ? SoapVersion.Soap11
89  					: null;
90  			soapVersion = soapVersion == null && contentType.startsWith( SoapVersion.Soap12.getContentType() ) ? SoapVersion.Soap12
91  					: soapVersion;
92  
93  			return soapVersion == null ? def : soapVersion;
94  		}
95  	}
96  
97  	public String getSoapActionHeader( String soapAction );
98  }