1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.support.soap;
14
15 import java.io.IOException;
16
17 import javax.xml.namespace.QName;
18
19 import org.apache.xmlbeans.SchemaType;
20 import org.apache.xmlbeans.SchemaTypeLoader;
21 import org.apache.xmlbeans.XmlBeans;
22 import org.apache.xmlbeans.XmlException;
23 import org.apache.xmlbeans.XmlObject;
24 import org.w3.x2003.x05.soapEnvelope.EnvelopeDocument;
25 import org.w3.x2003.x05.soapEnvelope.FaultDocument;
26
27 import com.eviware.soapui.SoapUI;
28 import com.eviware.soapui.impl.wsdl.support.Constants;
29 import com.eviware.soapui.support.StringUtils;
30
31 /***
32 * SoapVersion for SOAP 1.2
33 *
34 * @author ole.matzura
35 */
36
37 public class SoapVersion12 extends AbstractSoapVersion
38 {
39 private final static QName envelopeQName = new QName( Constants.SOAP12_ENVELOPE_NS, "Envelope" );
40 private final static QName bodyQName = new QName( Constants.SOAP12_ENVELOPE_NS, "Body" );
41 private final static QName faultQName = new QName( Constants.SOAP11_ENVELOPE_NS, "Fault" );
42 private final static QName headerQName = new QName( Constants.SOAP12_ENVELOPE_NS, "Header" );
43 public final static SoapVersion12 instance = new SoapVersion12();
44
45 private SchemaTypeLoader soapSchema;
46 private XmlObject soapSchemaXml;
47 private XmlObject soapEncodingXml;
48
49 private SoapVersion12()
50 {
51 ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
52 Thread.currentThread().setContextClassLoader( SoapUI.class.getClassLoader() );
53
54 try
55 {
56 soapSchemaXml = XmlObject.Factory.parse( SoapUI.class
57 .getResource( "/com/eviware/soapui/resources/xsds/soapEnvelope12.xsd" ) );
58 soapSchema = XmlBeans.loadXsd( new XmlObject[] { soapSchemaXml } );
59 soapEncodingXml = XmlObject.Factory.parse( SoapUI.class
60 .getResource( "/com/eviware/soapui/resources/xsds/soapEncoding12.xsd" ) );
61 }
62 catch( Exception e )
63 {
64 SoapUI.logError( e );
65 }
66 finally
67 {
68 Thread.currentThread().setContextClassLoader( contextClassLoader );
69 }
70 }
71
72 public String getEncodingNamespace()
73 {
74 return "http://www.w3.org/2003/05/soap-encoding";
75 }
76
77 public XmlObject getSoapEncodingSchema() throws XmlException, IOException
78 {
79 return soapEncodingXml;
80 }
81
82 public XmlObject getSoapEnvelopeSchema() throws XmlException, IOException
83 {
84 return soapSchemaXml;
85 }
86
87 public String getEnvelopeNamespace()
88 {
89 return Constants.SOAP12_ENVELOPE_NS;
90 }
91
92 public SchemaType getEnvelopeType()
93 {
94 return EnvelopeDocument.type;
95 }
96
97 public String toString()
98 {
99 return "SOAP 1.2";
100 }
101
102 public String getContentTypeHttpHeader( String encoding, String soapAction )
103 {
104 String result = getContentType();
105
106 if( encoding != null && encoding.trim().length() > 0 )
107 result += ";charset=" + encoding;
108
109 if( StringUtils.hasContent( soapAction ) )
110 result += ";action=" + StringUtils.quote( soapAction );
111
112 return result;
113 }
114
115 public String getSoapActionHeader( String soapAction )
116 {
117
118 return null;
119 }
120
121 public String getContentType()
122 {
123 return "application/soap+xml";
124 }
125
126 public QName getBodyQName()
127 {
128 return bodyQName;
129 }
130
131 public QName getEnvelopeQName()
132 {
133 return envelopeQName;
134 }
135
136 public QName getHeaderQName()
137 {
138 return headerQName;
139 }
140
141 protected SchemaTypeLoader getSoapEnvelopeSchemaLoader()
142 {
143 return soapSchema;
144 }
145
146 public static QName getFaultQName()
147 {
148 return faultQName;
149 }
150
151 public SchemaType getFaultType()
152 {
153 return FaultDocument.type;
154 }
155
156 public String getName()
157 {
158 return "SOAP 1.2";
159 }
160
161 public String getFaultDetailNamespace()
162 {
163 return getEnvelopeNamespace();
164 }
165 }