# MySoap11ServiceControl.jcx Sample

This topic inludes the source code for the MySoap11ServiceControl.jcx Sample.

## Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/SamplesApp/WebServices/soapHeaders/

## Sample Source Code

`001 package soapHeaders; 002 003 /** 004 * @jc:location http-url="mySoap11Service.jws" jms-url="mySoap11Service.jws" 005 * @jc:wsdl file="#mySoap11ServiceWsdl" 006 * @editor-info:link autogen-style="java" source="mySoap11Service.jws" autogen="true" 007 */ 008 public interface mySoap11ServiceControl extends com.bea.control.ControlExtension, com.bea.control.ServiceControl 009 { 010 011 /** 012 * In this method, a header is created using HeaderDocument.Factory.Parse. The FirstChild is extracted into header, which is type Element. The header is put into place using the JwsContext service method, setOutputHeaders. The format of the Element header is: firstChild localName = "Header" name = "SOAP-ENV:Header" namespaceURI= "http://schemas-xmlsoap.org/soap/envelope/" firstChild localName = "content" name = "my:content" namespaceURI= "http://my.com/uri/" firstChild data = "Context Text" 013 */ 014 public void myMethod (); 015 016 /** 017 * The header can be obtained by using the JwsContext interface getInputHeaders() is the compliment to setOutputHeaders() used in myMethod to add the header and the result is formated exactly the same way. You can extract some of the header by using the methods that come with the Element interface. getNodeName extracts the header name "soapenv:Header" getTagName extracts the tag name "soapenv:Header" Note that the header that is retrieved is that of the SOAP envelope. To get the rest of the header information you have to traverse the tree that is created. See the multipleHeaders.jws. 018 */ 019 public java.lang.String[] GetHeader (); 020 021 /** 022 * getProtocol is in the JwsContext interface. It returns a type Protocol, which is made up of an ID and the text name of the protocol type. The Protocol class also contains the list of protocols that it refers to. The Protocol class has a method by the name of getName that returns the name of the protocol. So, by using getName, you can tell if this is a SOAP protocol or some other type of protocol. 023 */ 024 public java.lang.String getThisProtocol (); 025 026 static final long serialVersionUID = 1L; 027 } 028 029 /** @common:define name="mySoap11ServiceWsdl" value:: 030 <?xml version="1.0" encoding="utf-8"?> 031 <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:conv="http://www.openuri.org/2002/04/soap/conversation/" xmlns:cw="http://www.openuri.org/2002/04/wsdl/conversation/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:jms="http://www.openuri.org/2002/04/wsdl/jms/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s0="http://www.openuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="http://www.openuri.org/"> 032 <types> 033 <s:schema elementFormDefault="qualified" targetNamespace="http://www.openuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:ope="http://www.openuri.org/"> 034 <s:element name="myMethod"> 035 <s:complexType> 036 <s:sequence/> 037 </s:complexType> 038 </s:element> 039 <s:element name="myMethodResponse"> 040 <s:complexType> 041 <s:sequence/> 042 </s:complexType> 043 </s:element> 044 <s:element name="GetHeader"> 045 <s:complexType> 046 <s:sequence/> 047 </s:complexType> 048 </s:element> 049 <s:element name="GetHeaderResponse"> 050 <s:complexType> 051 <s:sequence> 052 <s:element name="GetHeaderResult" type="ope:ArrayOfString" minOccurs="0"/> 053 </s:sequence> 054 </s:complexType> 055 </s:element> 056 <s:element name="ArrayOfString" nillable="true" type="ope:ArrayOfString"/> 057 <s:element name="getThisProtocol"> 058 <s:complexType> 059 <s:sequence/> 060 </s:complexType> 061 </s:element> 062 <s:element name="getThisProtocolResponse"> 063 <s:complexType> 064 <s:sequence> 065 <s:element name="getThisProtocolResult" type="s:string" minOccurs="0"/> 066 </s:sequence> 067 </s:complexType> 068 </s:element> 069 <s:element name="string" nillable="true" type="s:string"/> 070 <s:complexType name="ArrayOfString"> 071 <s:sequence> 072 <s:element name="String" type="s:string" nillable="true" minOccurs="0" maxOccurs="unbounded"/> 073 </s:sequence> 074 </s:complexType> 075 </s:schema> 076 077 </types> 078 <message name="myMethodSoapIn"> 079 <part name="parameters" element="s0:myMethod"/> 080 </message> 081 <message name="myMethodSoapOut"> 082 <part name="parameters" element="s0:myMethodResponse"/> 083 </message> 084 <message name="GetHeaderSoapIn"> 085 <part name="parameters" element="s0:GetHeader"/> 086 </message> 087 <message name="GetHeaderSoapOut"> 088 <part name="parameters" element="s0:GetHeaderResponse"/> 089 </message> 090 <message name="getThisProtocolSoapIn"> 091 <part name="parameters" element="s0:getThisProtocol"/> 092 </message> 093 <message name="getThisProtocolSoapOut"> 094 <part name="parameters" element="s0:getThisProtocolResponse"/> 095 </message> 096 <message name="myMethodHttpGetIn"/> 097 <message name="myMethodHttpGetOut"/> 098 <message name="GetHeaderHttpGetIn"/> 099 <message name="GetHeaderHttpGetOut"> 100 <part name="Body" element="s0:ArrayOfString"/> 101 </message> 102 <message name="getThisProtocolHttpGetIn"/> 103 <message name="getThisProtocolHttpGetOut"> 104 <part name="Body" element="s0:string"/> 105 </message> 106 <message name="myMethodHttpPostIn"/> 107 <message name="myMethodHttpPostOut"/> 108 <message name="GetHeaderHttpPostIn"/> 109 <message name="GetHeaderHttpPostOut"> 110 <part name="Body" element="s0:ArrayOfString"/> 111 </message> 112 <message name="getThisProtocolHttpPostIn"/> 113 <message name="getThisProtocolHttpPostOut"> 114 <part name="Body" element="s0:string"/> 115 </message> 116 <portType name="mySoap11ServiceSoap"> 117 <operation name="myMethod"> 118 <documentation>In this method, a header is created using HeaderDocument.Factory.Parse. The FirstChild is extracted into header, which is type Element. The header is put into place using the JwsContext service method, setOutputHeaders. The format of the Element header is: firstChild localName = "Header" name = "SOAP-ENV:Header" namespaceURI= "http://schemas-xmlsoap.org/soap/envelope/" firstChild localName = "content" name = "my:content" namespaceURI= "http://my.com/uri/" firstChild data = "Context Text"</documentation> 119 <input message="s0:myMethodSoapIn"/> 120 <output message="s0:myMethodSoapOut"/> 121 </operation> 122 <operation name="GetHeader"> 123 <documentation>The header can be obtained by using the JwsContext interface getInputHeaders() is the compliment to setOutputHeaders() used in myMethod to add the header and the result is formated exactly the same way. You can extract some of the header by using the methods that come with the Element interface. getNodeName extracts the header name "soapenv:Header" getTagName extracts the tag name "soapenv:Header" Note that the header that is retrieved is that of the SOAP envelope. To get the rest of the header information you have to traverse the tree that is created. See the multipleHeaders.jws.</documentation> 124 <input message="s0:GetHeaderSoapIn"/> 125 <output message="s0:GetHeaderSoapOut"/> 126 </operation> 127 <operation name="getThisProtocol"> 128 <documentation>getProtocol is in the JwsContext interface. It returns a type Protocol, which is made up of an ID and the text name of the protocol type. The Protocol class also contains the list of protocols that it refers to. The Protocol class has a method by the name of getName that returns the name of the protocol. So, by using getName, you can tell if this is a SOAP protocol or some other type of protocol.</documentation> 129 <input message="s0:getThisProtocolSoapIn"/> 130 <output message="s0:getThisProtocolSoapOut"/> 131 </operation> 132 </portType> 133 <portType name="mySoap11ServiceHttpGet"> 134 <operation name="myMethod"> 135 <documentation>In this method, a header is created using HeaderDocument.Factory.Parse. The FirstChild is extracted into header, which is type Element. The header is put into place using the JwsContext service method, setOutputHeaders. The format of the Element header is: firstChild localName = "Header" name = "SOAP-ENV:Header" namespaceURI= "http://schemas-xmlsoap.org/soap/envelope/" firstChild localName = "content" name = "my:content" namespaceURI= "http://my.com/uri/" firstChild data = "Context Text"</documentation> 136 <input message="s0:myMethodHttpGetIn"/> 137 <output message="s0:myMethodHttpGetOut"/> 138 </operation> 139 <operation name="GetHeader"> 140 <documentation>The header can be obtained by using the JwsContext interface getInputHeaders() is the compliment to setOutputHeaders() used in myMethod to add the header and the result is formated exactly the same way. You can extract some of the header by using the methods that come with the Element interface. getNodeName extracts the header name "soapenv:Header" getTagName extracts the tag name "soapenv:Header" Note that the header that is retrieved is that of the SOAP envelope. To get the rest of the header information you have to traverse the tree that is created. See the multipleHeaders.jws.</documentation> 141 <input message="s0:GetHeaderHttpGetIn"/> 142 <output message="s0:GetHeaderHttpGetOut"/> 143 </operation> 144 <operation name="getThisProtocol"> 145 <documentation>getProtocol is in the JwsContext interface. It returns a type Protocol, which is made up of an ID and the text name of the protocol type. The Protocol class also contains the list of protocols that it refers to. The Protocol class has a method by the name of getName that returns the name of the protocol. So, by using getName, you can tell if this is a SOAP protocol or some other type of protocol.</documentation> 146 <input message="s0:getThisProtocolHttpGetIn"/> 147 <output message="s0:getThisProtocolHttpGetOut"/> 148 </operation> 149 </portType> 150 <portType name="mySoap11ServiceHttpPost"> 151 <operation name="myMethod"> 152 <documentation>In this method, a header is created using HeaderDocument.Factory.Parse. The FirstChild is extracted into header, which is type Element. The header is put into place using the JwsContext service method, setOutputHeaders. The format of the Element header is: firstChild localName = "Header" name = "SOAP-ENV:Header" namespaceURI= "http://schemas-xmlsoap.org/soap/envelope/" firstChild localName = "content" name = "my:content" namespaceURI= "http://my.com/uri/" firstChild data = "Context Text"</documentation> 153 <input message="s0:myMethodHttpPostIn"/> 154 <output message="s0:myMethodHttpPostOut"/> 155 </operation> 156 <operation name="GetHeader"> 157 <documentation>The header can be obtained by using the JwsContext interface getInputHeaders() is the compliment to setOutputHeaders() used in myMethod to add the header and the result is formated exactly the same way. You can extract some of the header by using the methods that come with the Element interface. getNodeName extracts the header name "soapenv:Header" getTagName extracts the tag name "soapenv:Header" Note that the header that is retrieved is that of the SOAP envelope. To get the rest of the header information you have to traverse the tree that is created. See the multipleHeaders.jws.</documentation> 158 <input message="s0:GetHeaderHttpPostIn"/> 159 <output message="s0:GetHeaderHttpPostOut"/> 160 </operation> 161 <operation name="getThisProtocol"> 162 <documentation>getProtocol is in the JwsContext interface. It returns a type Protocol, which is made up of an ID and the text name of the protocol type. The Protocol class also contains the list of protocols that it refers to. The Protocol class has a method by the name of getName that returns the name of the protocol. So, by using getName, you can tell if this is a SOAP protocol or some other type of protocol.</documentation> 163 <input message="s0:getThisProtocolHttpPostIn"/> 164 <output message="s0:getThisProtocolHttpPostOut"/> 165 </operation> 166 </portType> 167 <binding name="mySoap11ServiceSoap" type="s0:mySoap11ServiceSoap"> 168 <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> 169 <operation name="myMethod"> 170 <soap:operation soapAction="http://www.openuri.org/myMethod" style="document"/> 171 <input> 172 <soap:body use="literal"/> 173 </input> 174 <output> 175 <soap:body use="literal"/> 176 </output> 177 </operation> 178 <operation name="GetHeader"> 179 <soap:operation soapAction="http://www.openuri.org/GetHeader" style="document"/> 180 <input> 181 <soap:body use="literal"/> 182 </input> 183 <output> 184 <soap:body use="literal"/> 185 </output> 186 </operation> 187 <operation name="getThisProtocol"> 188 <soap:operation soapAction="http://www.openuri.org/getThisProtocol" style="document"/> 189 <input> 190 <soap:body use="literal"/> 191 </input> 192 <output> 193 <soap:body use="literal"/> 194 </output> 195 </operation> 196 </binding> 197 <binding name="mySoap11ServiceHttpGet" type="s0:mySoap11ServiceHttpGet"> 198 <http:binding verb="GET"/> 199 <operation name="myMethod"> 200 <http:operation location="/myMethod"/> 201 <input> 202 <http:urlEncoded/> 203 </input> 204 <output/> 205 </operation> 206 <operation name="GetHeader"> 207 <http:operation location="/GetHeader"/> 208 <input> 209 <http:urlEncoded/> 210 </input> 211 <output> 212 <mime:mimeXml part="Body"/> 213 </output> 214 </operation> 215 <operation name="getThisProtocol"> 216 <http:operation location="/getThisProtocol"/> 217 <input> 218 <http:urlEncoded/> 219 </input> 220 <output> 221 <mime:mimeXml part="Body"/> 222 </output> 223 </operation> 224 </binding> 225 <binding name="mySoap11ServiceHttpPost" type="s0:mySoap11ServiceHttpPost"> 226 <http:binding verb="POST"/> 227 <operation name="myMethod"> 228 <http:operation location="/myMethod"/> 229 <input> 230 <mime:content type="application/x-www-form-urlencoded"/> 231 </input> 232 <output/> 233 </operation> 234 <operation name="GetHeader"> 235 <http:operation location="/GetHeader"/> 236 <input> 237 <mime:content type="application/x-www-form-urlencoded"/> 238 </input> 239 <output> 240 <mime:mimeXml part="Body"/> 241 </output> 242 </operation> 243 <operation name="getThisProtocol"> 244 <http:operation location="/getThisProtocol"/> 245 <input> 246 <mime:content type="application/x-www-form-urlencoded"/> 247 </input> 248 <output> 249 <mime:mimeXml part="Body"/> 250 </output> 251 </operation> 252 </binding> 253 <service name="mySoap11Service"> 254 <port name="mySoap11ServiceSoap" binding="s0:mySoap11ServiceSoap"> 255 <soap:address location="http://localhost:7001/soapHeaders/mySoap11Service.jws"/> 256 </port> 257 <port name="mySoap11ServiceHttpGet" binding="s0:mySoap11ServiceHttpGet"> 258 <http:address location="http://localhost:7001/soapHeaders/mySoap11Service.jws"/> 259 </port> 260 <port name="mySoap11ServiceHttpPost" binding="s0:mySoap11ServiceHttpPost"> 261 <http:address location="http://localhost:7001/soapHeaders/mySoap11Service.jws"/> 262 </port> 263 </service> 264 </definitions> 265 * :: 266 */`