|
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.ax
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,java.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/services/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 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?
|
- RE: SOAP header and patching problem Julia Tertyshnaya
- RE: SOAP header and patching problem St-Germain, Sylvain
