You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by Tom Leuntjens <To...@korfina.be> on 2002/06/11 15:32:25 UTC

RE: Correct way to add Apache SOAP Header ? bis

Tcpmon doen't even react when I fill in 
 
Host: www.yahoo.com <http://www.yahoo.com/> 
Port: 80
Listen on port 80 ..
 
And I surf to www.yahoo.com <http://www.yahoo.com/> 
 
So I'm adraid that wont be much of a help :-(
 
-----Original Message-----
From: Tom Leuntjens 
Sent: Tuesday, June 11, 2002 3:17 PM
To: soap-user@xml.apache.org
Subject: RE: Correct way to add Apache SOAP Header ?
 
Yep that's correct ..
 
 
 
Ive started the tcpmon ..
 
The service I'm connecting to from in my code , I don't define port so
that must be 80 ...
 
I keep getting waiting for connection ...
 
I run my java code from command prompt ..
How important is the listen port ?
If I choose 80 I get JVM_bind error ..  (ive shutdown my server) .. it
works ..
I keep getting waiting for connection ...
 
The toString() of the call (for my code at the time that doesn't work)
gives this : 
[Header=[Attributes={ Build="0" Revision="0" xmlns:Version=""
Identification="SK
ARABEEPRO" Minor="0" Major="0"}] [HeaderEntries={}]] [methodName=Ping]
[targetOb
jectURI=leftthisouttopostonforum] [encodingStyleURI=Co
nstants.NS_URI_SOAP_ENC] [SOAPContext=[Parts={}]] [Params={}]
 
 
 
 
 
 
 
 
 
 
-----Original Message-----
From: Wimmer, Matthias [mailto:matthias.wimmer@scr.siemens.com] 
Sent: Tuesday, June 11, 2002 3:01 PM
To: 'soap-user@xml.apache.org'
Subject: RE: Correct way to add Apache SOAP Header ?
 
Ok,
 
so if I am not completely mistaken, your message needs a header like the
one you quoted, right? And which kind of header does your code produce?
If you are not sure, try the TCPMonitor. You start it with:   
 
                 java org.apache.axis.utils.tcpmon 
 
I think this tool is very useful.
 
Matt
-----Original Message-----
From: Tom Leuntjens [mailto:Tom.Leuntjens@korfina.be]
Sent: Tuesday, June 11, 2002 8:57 AM
To: soap-user@xml.apache.org
Subject: RE: Correct way to add Apache SOAP Header ?
The problem is that I need to compose this little piece header ... and
add it to the call (I think) ..
 
  <soap:Header>
    <Version Identification="SKARABEEPRO" Major="0" Minor="0" Build="0"
Revision="0" xmlns="XXX" />
  </soap:Header>
 
 
I' don't really see how I need to do this with APACHE SOAP API
 
Code so far .....
 
import java.io.*;
import java.util.*;
import java.net.*;
import org.w3c.dom.*;
import org.apache.soap.util.xml.*;
import org.apache.soap.*;
import org.apache.soap.encoding.*;
import org.apache.soap.encoding.soapenc.*;
import org.apache.soap.rpc.*;
import org.apache.soap.transport.http.SOAPHTTPConnection;
 
public class testClient {
 
            public static void main(String[] args) throws Exception {
 
                        URL url = new URL
("http://xxx/dataswitch23.asmx");
                        String SOAPAction = "http://xxx/core23/Ping";
                        SOAPMappingRegistry smr = new
SOAPMappingRegistry();
                        StringDeserializer sd = new StringDeserializer
();
                        smr.mapTypes (Constants.NS_URI_SOAP_ENC, new
QName ("", "Result"), null, null, sd);
 
 
                        // create the transport and set parameters
                        SOAPHTTPConnection st = new
SOAPHTTPConnection();
                        st.setUserName("xxxx");
                        st.setPassword("xxx");
 
                        // create the header
                        Header myHeader = new Header();
                        myHeader.declareNamespace("", " XXX ");
                        myHeader.setAttribute(new QName("",
"Identification"), "SKARABEEPRO");
                        myHeader.setAttribute(new QName("", "Major"),
"0");
                        myHeader.setAttribute(new QName("", "Minor"),
"0");
                        myHeader.setAttribute(new QName("", "Revision"),
"0");
                        myHeader.setAttribute(new QName("", "Build"),
"0");
 
/*
 
System.out.println("\n------------------------------------------------\n
");
                        System.out.println(myHeader.toString());
*/
 
 
                        // build the call.
                        Call call = new Call ();
                        call.setSOAPTransport(st);
                        call.setSOAPMappingRegistry (smr);
                        call.setTargetObjectURI
("http://xxx/service/dataswitch23.asmx");
                        call.setMethodName("Ping");
                        call.setEncodingStyleURI
("Constants.NS_URI_SOAP_ENC");
                        call.setHeader(myHeader);
 
 
/*
 
System.out.println("\n------------------------------------------------\n
");
                        System.out.println(call.toString());
 
System.out.println("\n------------------------------------------------\n
");
*/
 
                        Response resp = null;
                        try {
                          resp = call.invoke (url, SOAPAction);
                        }
                        catch (SOAPException e) {
                                    System.err.println("Caught
SOAPException (" + e.getFaultCode () + "): " + e.getMessage ());
                                    return;
                        }
 
                        // check response
                        if (resp != null && !resp.generatedFault()) {
                           Parameter ret = resp.getReturnValue();
                          Object value = ret.getValue();
 
                          System.out.println ("Answer--> " + value);
                        }
                        else {
                                    Fault fault = resp.getFault ();
                                    System.err.println ("Generated
fault: ");
                                    System.out.println (" Fault Code = "
+ fault.getFaultCode());
                                    System.out.println (" Fault String =
" + fault.getFaultString());
                        }
            }
}
 
 
the error I keep getting ...
Server did not find required Version SOAP header in the message
 
 
 
-----Original Message-----
From: Wimmer, Matthias [mailto:matthias.wimmer@scr.siemens.com] 
Sent: Tuesday, June 11, 2002 2:42 PM
To: 'soap-user@xml.apache.org'
Subject: RE: Correct way to add Apache SOAP Header ?
 
Tom:
 
What is your problem? Doesn't it work? So below you will find an example
I found:
 
        Element emailElem = doc.createElementNS(
"http://any.namespace.com",  "EMail");
        emailElem.appendChild( ... );
        SOAPEnvelope reqEnv = new SOAPEnvelope();
        reqEnv.addHeader( new SOAPHeader(emailElem ));
        reqEnv.addBodyElement( ... );
        
        // Invoke the web service
        Call call = new Call( url );
        SOAPEnvelope respEnv = call.invoke(reqEnv);
I hope it works like this.
 
best regards
Matthias Wimmer
-----Original Message-----
From: Tom Leuntjens [mailto:Tom.Leuntjens@korfina.be]
Sent: Tuesday, June 11, 2002 7:01 AM
To: soap-user@xml.apache.org
Subject: Correct way to add Apache SOAP Header ?
Hi, 
So far im creating the call and i get this :
System.Web.Services.Protocols.SoapHeaderException: Server did not find
required Version SOAP header in the message. 
So I have been trying to add the header like this but to no avail .. 
 
 
// create the header
Header myHeader = new Header();
myHeader.declareNamespace("Version", "");
 
myHeader.setAttribute(new QName("", "Identification"), "SKARABEEPRO");
 
myHeader.setAttribute(new QName("", "Major"), "0");
myHeader.setAttribute(new QName("", "Minor"), "0");
myHeader.setAttribute(new QName("", "Revision"), "0");
myHeader.setAttribute(new QName("", "Build"), "0");
 
//add the header to the call ...
call.setHeader(myHeader);

Can somebody can give me some more info on how to do this ? What is the
correct way to add the header (details below)? Don't seem to find any
info about it ... 
Any help is appreciated ..
Thanx
Regards,
Tom

The service requires this call: 
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <Version Identification="SKARABEEPRO" Major="0" Minor="0" Build="0"
Revision="0" xmlns="leftthisouttopost" />
  </soap:Header>
  <soap:Body>
    <Ping xmlns="leftthisouttopost" />
  </soap:Body>
</soap:Envelope>

The toString() of the call (for my code at the time that doesn't work)
gives this : 
[Header=[Attributes={ Build="0" Revision="0" xmlns:Version=""
Identification="SK
ARABEEPRO" Minor="0" Major="0"}] [HeaderEntries={}]] [methodName=Ping]
[targetOb
jectURI=leftthisouttopostonforum] [encodingStyleURI=Co
nstants.NS_URI_SOAP_ENC] [SOAPContext=[Parts={}]] [Params={}]