So far, browsing to http://localhost:8080/axis/services/EchoHeaders returns
EchoHeaders
Hi there, this is an AXIS service!
Perhaps there will be a form for invoking the service here...
source:
<h1>EchoHeaders</h1>
<p>Hi there, this is an AXIS service!</p>
<i>Perhaps there will be a form for invoking the service here...</i>
So I assume somebody in the Axis instigator :-) has thought of returning
HTML to the client from a servlet. But I still cannot get header data from
(though I'm sure I've got it all screwed up):
public class EchoHeaders extends HttpServlet {
private String endpoint =
"http://localhost:8080/axis/services/EchoHeaders";
private String ret = "";
private Service service = null;
private Call call = null;
public void doGet( HttpServletRequest req, HttpServletResponse res )
throws ServletException, IOException {
doPost( req, res );
}
public void doPost( HttpServletRequest req, HttpServletResponse res
) throws ServletException, IOException {
res.setContentType( "text/html" );
Writer out = res.getWriter();
try {
service = new Service();
call = ( Call ) service.createCall();
call.setTargetEndpointAddress( new URL( endpoint ));
call.setOperationName( new QName(
"http://soapinterop.org/", "echoHeaders" ));
call.invoke( new Object[] { "list" });
} catch( ServiceException e ) {
e.printStackTrace();
}
if( !req.getParameter( "list" ).equals( "" ) ) {
Enumeration headers = req.getHeaderNames();
List list = new ArrayList();
while( headers.hasMoreElements() ) {
String h = ( String ) headers.nextElement();
String header = h + ":" + req.getHeader( h
);
list.add( header );
}
String[] results = new String[ list.size() ];
for( int i = 0; i < list.size(); i++ ) {
out.write(( String ) list.get( i ));
}
}
if( !req.getParameter( "whoami" ).equals( "" ) ) {
String remote = req.getRemoteHost();
out.write( "\n\nI am " + remote );
}
if( !req.getParameter( "echo" ).equals( "" ) ) {
String echo = req.getParameter( "echo" );
out.write( "\n\n" + echo );
}
}
}