sandeep1984
asked on
Help Needed with SOAP And Apache Axis
Hi.,
I am trying to develop a simple SOAP application using Axis.
I deployed axis in Apache Tomcat 6.
I have given server and client code in code snippet.
And when I try to execute the program I am getting this Exception in Tomcat Console
AxisFault
faultCode: {http://xml.apache.org/axis/}Client.NoSOAPAction
faultSubcode:
faultString: no SOAPAction header!
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:no SOAPAction header!
at org.apache.axis.transport. http.AxisS ervlet.get SoapAction (AxisServl et.java:10 13)
at org.apache.axis.transport. http.AxisS ervlet.doP ost(AxisSe rvlet.java :678)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 710)
at org.apache.axis.transport. http.AxisS ervletBase .service(A xisServlet Base.java: 327)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 803)
at org.apache.catalina.core.A pplication FilterChai n.internal DoFilter(A pplication FilterChai n.java:290 )
at org.apache.catalina.core.A pplication FilterChai n.doFilter (Applicati onFilterCh ain.java:2 06)
at org.apache.catalina.core.S tandardWra pperValve. invoke(Sta ndardWrapp erValve.ja va:233)
at org.apache.catalina.core.S tandardCon textValve. invoke(Sta ndardConte xtValve.ja va:175)
at org.apache.catalina.core.S tandardHos tValve.inv oke(Standa rdHostValv e.java:128 )
at org.apache.catalina.valves .ErrorRepo rtValve.in voke(Error ReportValv e.java:102 )
at org.apache.catalina.core.S tandardEng ineValve.i nvoke(Stan dardEngine Valve.java :109)
at org.apache.catalina.connec tor.Coyote Adapter.se rvice(Coyo teAdapter. java:263)
at org.apache.coyote.http11.H ttp11AprPr ocessor.pr ocess(Http 11AprProce ssor.java: 852)
at org.apache.coyote.http11.H ttp11AprPr otocol$Htt p11Connect ionHandler .process(H ttp11AprPr otocol.jav a:584)
at org.apache.tomcat.util.net .AprEndpoi nt$Worker. run(AprEnd point.java :1508)
at java.lang.Thread.run(Unkno wn Source)
{http://xml.apache.org/axis/}hostname:GSPCW046
no SOAPAction header!
at org.apache.axis.transport. http.AxisS ervlet.get SoapAction (AxisServl et.java:10 13)
at org.apache.axis.transport. http.AxisS ervlet.doP ost(AxisSe rvlet.java :678)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 710)
at org.apache.axis.transport. http.AxisS ervletBase .service(A xisServlet Base.java: 327)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 803)
at org.apache.catalina.core.A pplication FilterChai n.internal DoFilter(A pplication FilterChai n.java:290 )
at org.apache.catalina.core.A pplication FilterChai n.doFilter (Applicati onFilterCh ain.java:2 06)
at org.apache.catalina.core.S tandardWra pperValve. invoke(Sta ndardWrapp erValve.ja va:233)
at org.apache.catalina.core.S tandardCon textValve. invoke(Sta ndardConte xtValve.ja va:175)
at org.apache.catalina.core.S tandardHos tValve.inv oke(Standa rdHostValv e.java:128 )
at org.apache.catalina.valves .ErrorRepo rtValve.in voke(Error ReportValv e.java:102 )
at org.apache.catalina.core.S tandardEng ineValve.i nvoke(Stan dardEngine Valve.java :109)
at org.apache.catalina.connec tor.Coyote Adapter.se rvice(Coyo teAdapter. java:263)
at org.apache.coyote.http11.H ttp11AprPr ocessor.pr ocess(Http 11AprProce ssor.java: 852)
at org.apache.coyote.http11.H ttp11AprPr otocol$Htt p11Connect ionHandler .process(H ttp11AprPr otocol.jav a:584)
at org.apache.tomcat.util.net .AprEndpoi nt$Worker. run(AprEnd point.java :1508)
at java.lang.Thread.run(Unkno wn Source)
Thanks.
I am trying to develop a simple SOAP application using Axis.
I deployed axis in Apache Tomcat 6.
I have given server and client code in code snippet.
And when I try to execute the program I am getting this Exception in Tomcat Console
AxisFault
faultCode: {http://xml.apache.org/axis/}Client.NoSOAPAction
faultSubcode:
faultString: no SOAPAction header!
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:no SOAPAction header!
at org.apache.axis.transport.
at org.apache.axis.transport.
at javax.servlet.http.HttpSer
at org.apache.axis.transport.
at javax.servlet.http.HttpSer
at org.apache.catalina.core.A
at org.apache.catalina.core.A
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.valves
at org.apache.catalina.core.S
at org.apache.catalina.connec
at org.apache.coyote.http11.H
at org.apache.coyote.http11.H
at org.apache.tomcat.util.net
at java.lang.Thread.run(Unkno
{http://xml.apache.org/axis/}hostname:GSPCW046
no SOAPAction header!
at org.apache.axis.transport.
at org.apache.axis.transport.
at javax.servlet.http.HttpSer
at org.apache.axis.transport.
at javax.servlet.http.HttpSer
at org.apache.catalina.core.A
at org.apache.catalina.core.A
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.valves
at org.apache.catalina.core.S
at org.apache.catalina.connec
at org.apache.coyote.http11.H
at org.apache.coyote.http11.H
at org.apache.tomcat.util.net
at java.lang.Thread.run(Unkno
Thanks.
My Server code is : MessageService.jws
(I have copied this file in CATALIA_HOME\webapps\axis folder).
import org.w3c.dom.Element;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPElement;
public class MessageService
{
public Element[] echoElements(Element [] elems)
{
return elems;
}
public void process(SOAPEnvelope req, SOAPEnvelope resp) throws javax.xml.soap.SOAPException
{
try
{
SOAPBody body = resp.getBody();
System.out.println("\n\n");
System.out.println(body);
System.out.println("\n\n");
Name ns0 = resp.createName("TestNS0", "ns0", "http://example.com");
Name ns1 = resp.createName("TestNS1", "ns1", "http://example.com");
SOAPElement bodyElmnt = body.addBodyElement(ns0);
SOAPElement el = bodyElmnt.addChildElement(ns1);
el.addTextNode("TEST RESPONSE");
}
catch(Exception exp)
{
exp.printStackTrace();
}
}
}
And Client Code is : TestClient.java
import java.io.ByteArrayInputStream;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPBody;
public class TestClient
{
public static void main(String [] args)
{
try
{
String xmlString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n" +
" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n" +
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
" <soapenv:Header>\n" +
" <shw:Hello xmlns:shw=\"http://localhost:8080/axis/MessageService.jws\">\n" +
" <shw:Myname>Tony</shw:Myname>\n" +
" </shw:Hello>\n" +
" </soapenv:Header>\n" +
" <soapenv:Body>\n" +
" <shw:process xmlns:shw=\"http://localhost:8080/axis/MessageService.jws\">\n" +
" <shw:City>GENT</shw:City>\n" +
" </shw:process>\n" +
" </soapenv:Body>\n" +
"</soapenv:Envelope>";
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage smsg = mf.createMessage(new MimeHeaders(), new ByteArrayInputStream(xmlString.getBytes()));
SOAPPart sp = smsg.getSOAPPart();
SOAPEnvelope se = (SOAPEnvelope)sp.getEnvelope();
SOAPConnection conn = SOAPConnectionFactory.newInstance().createConnection();
SOAPMessage response = conn.call(smsg, "http://localhost:8080/axis/MessageService.jws");
System.out.println("Response : " + response.getSOAPBody());
}
catch (Exception e)
{
System.err.println(e.toString());
}
}
}
ASKER
setProperty method s not available in MimeHeaders class.
sorry its addHeader()
ASKER
I tried with this. Still getting the same error.
What might be the problem??
I am using MessageService.jws
Should I use "http://localhost:8080/axis/MessageService.jws?method=process"
or
"http://localhost:8080/axis/MessageService.jws"
for Call.SOAPACTION_URI_PROPER TY
What might be the problem??
I am using MessageService.jws
Should I use "http://localhost:8080/axis/MessageService.jws?method=process"
or
"http://localhost:8080/axis/MessageService.jws"
for Call.SOAPACTION_URI_PROPER
SOAPConnection conn = SOAPConnectionFactory.newInstance().createConnection();
MimeHeaders h = new MimeHeaders();
SOAPMessage smsg = mf.createMessage(h, new ByteArrayInputStream(xmlString.getBytes()));
h.addHeader(Call.SOAPACTION_USE_PROPERTY, "true");
h.addHeader(Call.SOAPACTION_URI_PROPERTY, "http://localhost:8080/axis/MessageService.jws?method=process");
SOAPMessage response = conn.call(smsg, "http://localhost:8080/axis/MessageService.jws");
System.out.println("Response : " + response.getSOAPBody());
ths is your URI, "http://localhost:8080/axis/MessageService.jws"
adding this should work,
But this can be achieved more easily with JAXWS,
get the wsdl, generate the client stubs
and use them to call the webservice method
its simpler and easier, all the packaging and trasport is taken care by it
adding this should work,
But this can be achieved more easily with JAXWS,
get the wsdl, generate the client stubs
and use them to call the webservice method
its simpler and easier, all the packaging and trasport is taken care by it
To get the exact SOAP action check your WSDL, or better search for "soapAction" in your WSDL you will find the exact Soap action you need to use for invocation.
The way to add soapAction's in axis is options.setAction("your url");
you may like to follow this
http://www.mail-archive.com/axis-user@ws.apache.org/msg13649.html
you may like to follow this
http://www.mail-archive.com/axis-user@ws.apache.org/msg13649.html
ASKER
How to create a wsdl for my JWS.
ASKER
I have installed the Service sing AdminClient as follows
I have copied MessageService.class to : CATALINA_HOME/webapps/axis /WEB-INF/c lasses.
Then I copied deploy.wsdd & undeploy.wsdd to : CATALINA_HOME/webapps/axis /WEB-INF.
deploy.wsdd:
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="MyService" provider="java:RPC">
<parameter name="className" value="MessageService"/>
<parameter name="allowedMethods" value="*"/>
</service>
</deployment>
undeploy.wsdd:
<undeployment xmlns="http://xml.apache.org/axis/wsdd/">
<service name="MessageService"/>
</undeployment>
Step 1: java -cp %CATALINA_HOME%\lib\axis.j ar;%CATALI NA_HOME%\l ib\jaxrpc. jar;%CATAL INA_HOME%\ lib\common s-logging- 1.1.jar;%C ATALINA_HO ME%\lib\co mmons-disc overy-0.2. jar;%CATAL INA_HOME%\ lib\activa tion.jar;% CATALINA_H OME%\lib\m ail.jar; org.apache.axis.client.Adm inClient deploy.wsdd
Step 2 : REM java -cp %CATALINA_HOME%\lib\axis.j ar;%CATALI NA_HOME%\l ib\jaxrpc. jar;%CATAL INA_HOME%\ lib\common s-logging- 1.1.jar;%C ATALINA_HO ME%\lib\co mmons-disc overy-0.2. jar;%CATAL INA_HOME%\ lib\activa tion.jar;% CATALINA_H OME%\lib\m ail.jar; org.apache.axis.client.Adm inClient -lhttp://localhost:8080/axis/services/AdminService deploy.wsdd
Now I am getting this Error :
SEVERE: SAAJ0008: Bad Response; /axis/MessageService
com.sun.xml.internal.messa ging.saaj. SOAPExcept ionImpl: java.security.PrivilegedAc tionExcept ion: com.sun.xml.internal.messa ging.saaj. SOAPExcept ionImpl: Bad response: (404/axis/MessageService
Should I have to specify anything in web.xml file??
I have copied MessageService.class to : CATALINA_HOME/webapps/axis
Then I copied deploy.wsdd & undeploy.wsdd to : CATALINA_HOME/webapps/axis
deploy.wsdd:
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="MyService" provider="java:RPC">
<parameter name="className" value="MessageService"/>
<parameter name="allowedMethods" value="*"/>
</service>
</deployment>
undeploy.wsdd:
<undeployment xmlns="http://xml.apache.org/axis/wsdd/">
<service name="MessageService"/>
</undeployment>
Step 1: java -cp %CATALINA_HOME%\lib\axis.j
Step 2 : REM java -cp %CATALINA_HOME%\lib\axis.j
Now I am getting this Error :
SEVERE: SAAJ0008: Bad Response; /axis/MessageService
com.sun.xml.internal.messa
Should I have to specify anything in web.xml file??
My Server Code : MessageService.java
import org.w3c.dom.Element;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPElement;
public class MessageService
{
public Element[] echoElements(Element [] elems)
{
return elems;
}
public void process(SOAPEnvelope req, SOAPEnvelope resp) throws javax.xml.soap.SOAPException
{
try
{
SOAPBody body = resp.getBody();
System.out.println("\n\n");
System.out.println(body);
System.out.println("\n\n");
Name ns0 = resp.createName("TestNS0", "ns0", "http://example.com");
Name ns1 = resp.createName("TestNS1", "ns1", "http://example.com");
SOAPElement bodyElmnt = body.addBodyElement(ns0);
SOAPElement el = bodyElmnt.addChildElement(ns1);
el.addTextNode("TEST RESPONSE");
}
catch(Exception exp)
{
System.out.println("Exception while receiving the request");
exp.printStackTrace();
}
}
}
Client Code : TestClient
import java.io.ByteArrayInputStream;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPFactory;
import javax.xml.soap.Name;
public class TestClient
{
public static void main(String [] args)
{
try
{
String xmlString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n" +
" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n" +
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
" <soapenv:Header>\n" +
" <shw:Hello xmlns:shw=\"http://localhost:8080/axis/MessageService\">\n" +
" <shw:Myname>Tony</shw:Myname>\n" +
" </shw:Hello>\n" +
" </soapenv:Header>\n" +
" <soapenv:Body>\n" +
" <shw:process xmlns:shw=\"http://localhost:8080/axis/MessageService\">\n" +
" <shw:City>GENT</shw:City>\n" +
" </shw:process>\n" +
" </soapenv:Body>\n" +
"</soapenv:Envelope>";
MessageFactory mf = MessageFactory.newInstance();
SOAPConnection conn = SOAPConnectionFactory.newInstance().createConnection();
MimeHeaders h = new MimeHeaders();
SOAPMessage smsg = mf.createMessage(h, new ByteArrayInputStream(xmlString.getBytes()));
h.addHeader(Call.SOAPACTION_USE_PROPERTY, "true");
h.addHeader(Call.SOAPACTION_URI_PROPERTY, "http://localhost:8080/axis/MessageService");
SOAPMessage response = conn.call(smsg, "http://localhost:8080/axis/MessageService");
System.out.println("Response : " + response.getSOAPBody());
}
catch (Exception e)
{
System.err.println(e.toString());
}
}
}
Sandeep, if you seriously want aviod all these headaches of dealing with SOAP messages and header better use axis Eclipse plugin or Eclipse WTP it solves you problem 90% you just need to do you basic stuff.
if you still want to continue in the same above way, first of check if your web service is up and running.
got to : http://localhost:8080/axis/services
let me know if you can see your MessagingService there, else we can start all over from the start.
if you still want to continue in the same above way, first of check if your web service is up and running.
got to : http://localhost:8080/axis/services
let me know if you can see your MessagingService there, else we can start all over from the start.
Also note that you are using Jax:RPC which is not very compatible or preferable :)
Take look at the simplest way of creating a web service using Eclipse WTP it take hardly 5 mins :)
http://www.webagesolutions.com/knowledgebase/javakb/jkb004/WTP_demo.htm
Take look at the simplest way of creating a web service using Eclipse WTP it take hardly 5 mins :)
http://www.webagesolutions.com/knowledgebase/javakb/jkb004/WTP_demo.htm
ASKER
I have changed it to provider="java:MSG"
In axis services list, I can see the service running.
In axis services list, I can see the service running.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
May I know why C grade??
ASKER
Sorry mate. I wanted to give you B, but by mistake.
Thanks for your answers.
Thanks for your answers.
and set
h.setProperty( Call.SOAPACTION_USE_PROPER
h.setProperty( Call.SOAPACTION_URI_PROPER