You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "St-Germain, Sylvain" <Sy...@cognos.com> on 2002/12/04 21:01:08 UTC
RE: SOAP header and patching problem
I have a patch on the way, only the test case has to be finalized... I can
send it to you.
-----Original Message-----
From: Julia Tertyshnaya [mailto:tertyshnaya@ftw.at]
Sent: Tuesday, November 26, 2002 5:57 AM
To: axis-user@xml.apache.org
Subject: SOAP header and patching problem
Hello all,
Sorry I sent the message in HTML format by mistake at first, this is the
text only.
I have problems with SOAP headers: I can create a SOAP header on the client
side and pack it into the SOAP envelope (using SOAPHeaderElement and
call.addHeader()), but my web service doesn't see the header.
I use Axis 1.0, Java 1.4 Tomcat 4.0.4.
I provide relevant fragments of client and service code below.
I've read everything I could find on this topic in this mailing list, tried
many things, but nothing helped until now. I did:
-changed service wsdl file in order it contains soap:header in binding (I
provide wsdl fragment later);
- tried to patch Axis with the patch
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13618
but patch program (patch-2.5.7-alpha from GNUWin32) doesn't patch it
correctly and class JavaStubWriter doesn't compile. When I correct it
manually it doesn't compile as well because of incorrect signature of
writeOperation method:
JavaStubWriter.java:308:
writeOperation(java.io.PrintWriter,javax.wsdl.BindingOperation,org.apache..a
x
is.wsdl.symbolTable.Parameters,java.lang.String,java.lang.String,boolean) in
org.apache.axis.wsdl.toJ
ava.JavaStubWriter cannot be applied to
(java.io.PrintWriter,javax.wsdl.BindingOperation,org.apache.a
xis.wsdl.symbolTable.Headers,org.apache.axis.wsdl.symbolTable.Parameters,jav
a.lang.String,java.lang.S
tring,boolean)
writeOperation(pw, operation, headers, parameters,
soapAction, opStyle,
Do I really have to patch Axis in order to use Soap Headers or there's
another way? Could maybe somebody send me the patched class JavaStubWriter?
Please help me to understand what I'm doing wrong.
Thank you very much.
Julia
*************************************************************************
Client code:
String nameSpace = "samples.auth.SoapHeaderAuthClient";
//Element root = doc.getDocumentElement();
Element root = doc.createElementNS(nameSpace, "xxx");
Element subElem = doc.createElementNS(nameSpace, "userName");
//Element subElem = doc.createElement("userName");
org.w3c.dom.Text text = doc.createTextNode("user1");
subElem.appendChild(text);
root.appendChild(subElem);
subElem = doc.createElementNS(nameSpace, "password");
//subElem = doc.createElement("password");
text = doc.createTextNode("psw");
subElem.appendChild(text);
root.appendChild(subElem);
org.apache.axis.message.SOAPHeaderElement head = new
org.apache.axis.message.SOAPHeaderElement(root);
//head.setActor("SoapHeaderAuthService");
head.setActor(SOAPConstants.URI_SOAP_ACTOR_NEXT);
head.setMustUnderstand(true);
System.out.println("actor has been set " + head.getActor());
System.out.println("must understand has been set " +
head.getMustUnderstand());
String endpoint =
"http://localhost:9090/axis/services/SoapHeaderAuth";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setOperationName("sayHello");
call.setReturnType( XMLType.XSD_STRING );
call.addHeader(head);
String res = (String)call.invoke( new Object [] {});
I can see Soap header with tcpmon in the Soap message
Although I set actor and "must understand" flag they are not visible in the
soap header at tcpmon. Why?
**************************************************************************
Service code:
public String sayHello(){
String s = "hello, ";
try{
MessageContext cox = MessageContext.getCurrentContext();
SOAPMessage mess = cox.getMessage();
System.out.println("got message context");
javax.xml.soap.SOAPPart part = mess.getSOAPPart();
System.out.println("got soap part");
SOAPEnvelope env = part.getEnvelope();
System.out.println("got envelope");
SOAPHeader header = env.getHeader();
System.out.println("got header");
//Iterator it = header.examineHeaderElements("");
//Iterator it =
header.examineHeaderElements("SoapHeaderAuthService");
Iterator it =
header.examineHeaderElements(SOAPConstants.URI_SOAP_ACTOR_NEXT);
System.out.println("got iterator " + it);
if (it.hasNext())
System.out.println("there's some header!");
else
System.out.println("there's no header");
while (it.hasNext()){
SOAPHeaderElement el = (SOAPHeaderElement)it.next();
System.out.println("got header element" + el);
}
}catch (SOAPException e){
e.printStackTrace();
}
return s;
}
I get "there's no header" output
***********************************************************************
wsdl file:
<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions
targetNamespace="http://localhost:8080/axis/services/SoapHeaderAuth/axis/ser
vices/SoapHeaderAuth" xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="http://localhost:8080/axis/services/SoapHeaderAuth/axis/services
/SoapHeaderAuth-impl"
xmlns:intf="http://localhost:8080/axis/services/SoapHeaderAuth/axis/services
/SoapHeaderAuth" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:message name="sayHelloResponse">
<wsdl:part name="return" type="xsd:string" />
</wsdl:message>
<wsdl:message name="sayHelloRequest" />
<wsdl:message name="header">
<part name="userName" type="xsd:string" />
<part name="password" type="xsd:string" />
</wsdl:message>
<wsdl:portType name="SoapHeaderAuthService">
<wsdl:operation name="sayHello">
<wsdl:input message="intf:sayHelloRequest" name="sayHelloRequest" />
<wsdl:output message="intf:sayHelloResponse" name="sayHelloResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SoapHeaderAuthSoapBinding"
type="intf:SoapHeaderAuthService">
<wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="sayHello">
<wsdlsoap:operation soapAction="" />
<wsdl:input name="sayHelloRequest">
<wsdlsoap:header message="header"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://localhost:8080/axis/services/SoapHeaderAuth/axis/services/
SoapHeaderAuth" use="encoded" />
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://localhost:8080/axis/services/SoapHeaderAuth/axis/services/
SoapHeaderAuth" use="encoded" />
</wsdl:input>
<wsdl:output name="sayHelloResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://localhost:8080/axis/services/SoapHeaderAuth/axis/services/
SoapHeaderAuth" use="encoded" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SoapHeaderAuthServiceService">
<wsdl:port binding="intf:SoapHeaderAuthSoapBinding" name="SoapHeaderAuth">
<wsdlsoap:address
location="http://localhost:8080/axis/services/SoapHeaderAuth" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
When I compile this file, no soap header support is generated (which is
normal behaivor withou patch, I guess).
How can I use soap headers implicitly? Do I need to modify the wsdl file in
that case?
------extPart_000_007B_01C29542.EC33E7C0
Content-Type: text/html;
charsetso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 5.50.4616.200" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Hello all,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Sorry I sent the message in HTML format by
mistake
at first, this is the text only.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I have problems with SOAP headers: I can create
a
SOAP header on the client side and pack it into the SOAP envelope (using
SOAPHeaderElement and call.addHeader()), but my web service doesn't see the
header.</FONT></DIV>
<DIV><FONT face=Arial size=2>I use Axis 1.0, Java 1.4 Tomcat
4.0.4.</FONT></DIV>
<DIV><FONT face=Arial size=2>I provide relevant fragments of client and
service
code below.</FONT></DIV>
<DIV><FONT face=Arial size=2>I've read everything I could find on this topic
in
this mailing list, tried many things, but nothing helped until now. I
did:</FONT></DIV>
<DIV><FONT face=Arial size=2>-changed service wsdl file in order it contains
soap:header in binding (I provide wsdl fragment later);</FONT></DIV>
<DIV><FONT face=Arial size=2>- tried to patch Axis with the patch <A
href="http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13618"><FONT
size=3>http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13618</FONT></A><FO
NT
size=3> </FONT></FONT></DIV>
<DIV><FONT face=Arial size=2>but patch program (patch-2.5.7-alpha from
GNUWin32)
doesn't patch it correctly and class JavaStubWriter doesn't compile. When I
correct it manually it doesn't compile as well because of incorrect
signature of
writeOperation method: </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>JavaStubWriter.java:308:
writeOperation(java.io.PrintWriter,javax.wsdl.BindingOperation,org.apache
boolean)
in org.apache.axis.wsdl.toJ<BR>ava.JavaStubWriter cannot be applied to
(java.io.PrintWriter,javax.wsdl.BindingOperation,org.apache.a<BR>xis.wsdl
ng.String,java.lang.S<BR>tring,boolean)<BR> &nb
sp;
writeOperation(pw, operation, headers, parameters, soapAction,
opStyle,<BR> </FONT></DIV>
<DIV><FONT face=Arial size=2>Do I really have to patch Axis in order to use
Soap
Headers or there's another way? Could maybe somebody send me the patched
class
JavaStubWriter?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Please help me to understand what I'm doing
wrong.
</FONT></DIV>
<DIV><FONT face=Arial size=2>Thank you very much.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Julia</FONT></DIV>
<DIV><FONT face=Arial
size=2>*********************************************************************
****</FONT></DIV>
<DIV><FONT face=Arial size=2>Client code:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial
size=2> String
nameSpace =
"samples.auth.SoapHeaderAuthClient";<BR>
//Element root =
doc.getDocumentElement();<BR>  
;
Element root = doc.createElementNS(nameSpace,
"xxx");<BR>
<BR> Element subElem =
doc.createElementNS(nameSpace,
"userName");<BR>
//Element
subElem =
doc.createElement("userName");<BR>
org.w3c.dom.Text text =
doc.createTextNode("user1");<BR> &n
bsp;
subElem.appendChild(text);<BR> &nbs
p;
root.appendChild(subElem);<BR> &nbs
p;
<BR> subElem =
doc.createElementNS(nameSpace,
"password");<BR>
//subElem
=
doc.createElement("password");<BR>
text =
doc.createTextNode("psw");<BR> &nbs
p;
subElem.appendChild(text);<BR> &nbs
p;
root.appendChild(subElem);<BR> &nbs
p;
<BR>
org.apache.axis.message.SOAPHeaderElement head = new
org.apache.axis.message.SOAPHeaderElement(root);<BR>
//head.setActor("SoapHeaderAuthService");<BR> &
nbsp;
head.setActor(SOAPConstants.URI_SOAP_ACTOR_NEXT); &nb
sp;
<BR>
head.setMustUnderstand(true);<BR> &
nbsp;
System.out.println("actor has been set " +
head.getActor());<BR>
System.out.println("must understand has been set " +
head.getMustUnderstand());<BR> &nbs
p;
<BR> String endpoint =
"<A
href="http://localhost:9090/axis/services/SoapHeaderAuth">http://localhost:9
090/axis/services/SoapHeaderAuth</A>";<BR> &nbs
p;
Service service = new
Service();<BR> Call
call =
(Call)
service.createCall();<BR> &nb
sp;
call.setTargetEndpointAddress( new java.net.URL(endpoint)
);<BR>
call.setOperationName("sayHello");<BR> &n
bsp;
call.setReturnType( XMLType.XSD_STRING
);<BR>
call.addHeader(head);<BR> &nb
sp;
String res = (String)call.invoke( new Object [] {});</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I can see Soap header with tcpmon in the Soap
message</FONT></DIV>
<DIV><FONT face=Arial size=2>Although I set actor and "must understand" flag
they are not visible in the soap header at tcpmon. Why?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial
size=2>*********************************************************************
*****</FONT></DIV>
<DIV><FONT face=Arial size=2>Service code:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> public String
sayHello(){<BR> String s = "hello,
";<BR>
try{<BR>
MessageContext cox =
MessageContext.getCurrentContext();<BR> &
nbsp;
SOAPMessage mess =
cox.getMessage();<BR> &
nbsp;
System.out.println("got message
context");<BR> &n
bsp;
javax.xml.soap.SOAPPart part =
mess.getSOAPPart();<BR>  
;
System.out.println("got soap
part");<BR>  
;
SOAPEnvelope env =
part.getEnvelope();<BR>  
;
System.out.println("got
envelope");<BR> &
nbsp;
SOAPHeader header =
env.getHeader();<BR> &n
bsp;
System.out.println("got
header");<BR> &nb
sp;
//Iterator it =
header.examineHeaderElements("");<BR> &nb
sp;
//Iterator it =
header.examineHeaderElements("SoapHeaderAuthService");<BR>
Iterator it =
header.examineHeaderElements(SOAPConstants.URI_SOAP_ACTOR_NEXT);<BR> &n
bsp;
System.out.println("got iterator " +
it);<BR>
if
(it.hasNext())<BR> &nbs
p;
System.out.println("there's some
header!");<BR> &n
bsp;
else
<BR>
System.out.println("there's no
header");<BR> &nb
sp;
while
(it.hasNext()){<BR> &nb
sp;
SOAPHeaderElement el =
(SOAPHeaderElement)it.next();<BR> &
nbsp;
System.out.println("got header element" +
el);<BR> }
<BR>
<BR> }catch (SOAPException
e){<BR>
e.printStackTrace();<BR>
}<BR> return
s;<BR>
}</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I get "there's no header" output</FONT></DIV>
<DIV><FONT face=Arial
size=2>*********************************************************************
**</FONT></DIV>
<DIV><FONT face=Arial size=2>wsdl file:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><?xml version="1.0" encoding="UTF-8" ?>
<BR><wsdl:definitions targetNamespace="<A
href="http://localhost:8080/axis/services/SoapHeaderAuth/axis/services/SoapH
eaderAuth">http://localhost:8080/axis/services/SoapHeaderAuth/axis/services/
SoapHeaderAuth</A>"
xmlns="<A
href="http://schemas.xmlsoap.org/wsdl/">http://schemas.xmlsoap.org/wsdl/</A>
"
xmlns:apachesoap="<A
href="http://xml.apache.org/xml-soap">http://xml.apache.org/xml-soap</A>"
xmlns:impl="<A
href="http://localhost:8080/axis/services/SoapHeaderAuth/axis/services/SoapH
eaderAuth-impl">http://localhost:8080/axis/services/SoapHeaderAuth/axis/serv
ices/SoapHeaderAuth-impl</A>"
xmlns:intf="<A
href="http://localhost:8080/axis/services/SoapHeaderAuth/axis/services/SoapH
eaderAuth">http://localhost:8080/axis/services/SoapHeaderAuth/axis/services/
SoapHeaderAuth</A>"
xmlns:soapenc="<A
href="http://schemas.xmlsoap.org/soap/encoding/">http://schemas.xmlsoap
xmlns:wsdl="<A
href="http://schemas.xmlsoap.org/wsdl/">http://schemas.xmlsoap.org/wsdl/</A>
"
xmlns:wsdlsoap="<A
href="http://schemas.xmlsoap.org/wsdl/soap/">http://schemas.xmlsoap.org/wsdl
/soap/</A>"
xmlns:xsd="<A
href="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</A>
"><BR><wsdl:message
name="sayHelloResponse"><BR> <wsdl:part name="return"
type="xsd:string" /> <BR> </wsdl:message><BR>
<wsdl:message name="sayHelloRequest" /> <BR> <wsdl:message
name="header"><BR> <part name="userName" type="xsd:string"
/><BR> <part name="password" type="xsd:string"
/><BR> </wsdl:message><BR><wsdl:portType
name="SoapHeaderAuthService"><BR><wsdl:operation
name="sayHello"><BR> <wsdl:input message="intf:sayHelloRequest"
name="sayHelloRequest" /> <BR> <wsdl:output
message="intf:sayHelloResponse" name="sayHelloResponse" /> <BR>
</wsdl:operation><BR> </wsdl:portType><BR><wsdl:binding
name="SoapHeaderAuthSoapBinding"
type="intf:SoapHeaderAuthService"><BR>
<wsdlsoap:binding style="rpc" transport="<A
href="http://schemas.xmlsoap.org/soap/http">http://schemas.xmlsoap.org/soap/
http</A>"
/> <BR><wsdl:operation name="sayHello"><BR>
<wsdlsoap:operation soapAction="" /> <BR><wsdl:input
name="sayHelloRequest"><BR> <wsdlsoap:header message="header"
encodingStyle="<A
href="http://schemas.xmlsoap.org/soap/encoding/">http://schemas.xmlsoap
namespace="<A
href="http://localhost:8080/axis/services/SoapHeaderAuth/axis/services/SoapH
eaderAuth">http://localhost:8080/axis/services/SoapHeaderAuth/axis/services/
SoapHeaderAuth</A>"
use="encoded" /> <BR> <wsdlsoap:body encodingStyle="<A
href="http://schemas.xmlsoap.org/soap/encoding/">http://schemas.xmlsoap
namespace="<A
href="http://localhost:8080/axis/services/SoapHeaderAuth/axis/services/SoapH
eaderAuth">http://localhost:8080/axis/services/SoapHeaderAuth/axis/services/
SoapHeaderAuth</A>"
use="encoded" /> <BR> </wsdl:input><BR><wsdl:output
name="sayHelloResponse"><BR> <wsdlsoap:body encodingStyle="<A
href="http://schemas.xmlsoap.org/soap/encoding/">http://schemas.xmlsoap
namespace="<A
href="http://localhost:8080/axis/services/SoapHeaderAuth/axis/services/SoapH
eaderAuth">http://localhost:8080/axis/services/SoapHeaderAuth/axis/services/
SoapHeaderAuth</A>"
use="encoded" /> <BR> </wsdl:output><BR>
</wsdl:operation><BR> </wsdl:binding><BR><wsdl:service
name="SoapHeaderAuthServiceService"><BR><wsdl:port
binding="intf:SoapHeaderAuthSoapBinding" name="SoapHeaderAuth"><BR>
<wsdlsoap:address location="<A
href="http://localhost:8080/axis/services/SoapHeaderAuth">http://localhost:8
080/axis/services/SoapHeaderAuth</A>"
/> <BR> </wsdl:port><BR>
</wsdl:service><BR>
</wsdl:definitions></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>When I compile this file, no soap header
support is
generated (which is normal behaivor withou patch, I guess).</FONT></DIV>
<DIV><FONT face=Arial size=2>How can I use soap headers implicitly? Do I
need to
modify the wsdl file in that case?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV></BODY></HTML>
This message may contain privileged and/or confidential information. If you
have received this e-mail in error or are not the intended recipient, you
may not use, copy, disseminate or distribute it; do not open any
attachments, delete it immediately from your system and notify the sender
promptly by e-mail that you have done so. Thank you.