On Thu, Jan 13, 2011 at 4:14 PM, Iskar <[email protected]> wrote: > > Hi, > > I have written a simple Web Service and deployed it to axis2-1.5.3's simple > web server, services.xml file looks like that: > > <service> > <parameter name="ServiceClass" locked="false">hp.main.WSMain</parameter> > <operation name="addSample"> > <messageReceiver > class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/> > </operation> > <operation name="addSampleTypes"> > <messageReceiver > class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/> > </operation> > <operation name="getSampleTypes"> > <messageReceiver > class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/> > </operation> > <operation name="getPrivileges"> > <messageReceiver > class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/> > </operation> > </service> > > When I call getSampleTypes using for example SoapUI application, everything > works correctly - server gives correct results. I wrote a client for that > web service in Java using the same axis2 jars. The code I used was from the > Axis2 site, I just added few more elements i needed. And now: when I send > incorrect request (for example, I omit a mandatory element), server > responses with a correct message. However, when the request is correct, I > get the: > org.apache.axis2.AxisFault: unknown > at > > org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:446) > at > > org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:371) > at > > org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:417) > at > > org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229) > at > org.apache.axis2.client.OperationClient.execute(OperationClient.java:165) > at > org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:540) > at > org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:521) > at hp.main.ClientMain.main(ClientMain.java:50) > > Here comes the code of the client: > > package hp.main; > > import org.apache.axiom.om.OMAbstractFactory; > import org.apache.axiom.om.OMElement; > import org.apache.axiom.om.OMFactory; > import org.apache.axiom.om.OMNamespace; > import org.apache.axis2.Constants; > import org.apache.axis2.addressing.EndpointReference; > import org.apache.axis2.client.Options; > import org.apache.axis2.client.ServiceClient; > import org.apache.log4j.PropertyConfigurator; > > public class ClientMain { > private static EndpointReference targetEPR = > new > EndpointReference("http://localhost:8080/axis2/services/TestWS"); > > public static OMElement createSampleTypesElement() { > OMFactory factory = OMAbstractFactory.getOMFactory(); > OMNamespace hpNamespace = > factory.createOMNamespace("http://www.test.com", "hp"); > OMNamespace hpcommNamespace = > factory.createOMNamespace("http://www.test.com/commons", "hpc"); > > OMElement reqRoot = factory.createOMElement("getSampleTypes", > hpNamespace); > OMElement userData = factory.createOMElement("UserData", > hpcommNamespace); > reqRoot.addChild(userData); > > OMElement loginElement = factory.createOMElement("Login", > hpcommNamespace); > userData.addChild(loginElement); > loginElement.addChild(factory.createOMText("test")); > > OMElement passwordElement = factory.createOMElement("test", > hpcommNamespace); > userData.addChild(passwordElement); > passwordElement.addChild(factory.createOMText("password")); > > return reqRoot; > } > > public static void main(String[] args) { > try { > PropertyConfigurator.configure("log/properties.txt"); > > OMElement getSampleTypes = createSampleTypesElement(); > > Options options = new Options(); > options.setTo(targetEPR); > options.setTransportInProtocol(Constants.TRANSPORT_HTTP); > > ServiceClient sender = new ServiceClient(); > sender.setOptions(options); > > OMElement result = sender.sendReceive(getSampleTypes); > System.out.println(result.getText()); > > OMElement statusElement = > (OMElement)result.getChildrenWithLocalName("Status").next(); > if (statusElement == null) { > System.out.println("statusElement jest pusty..."); > } else System.out.println("Status = " + > statusElement.getText()); > > OMElement messageElement = > (OMElement)result.getChildrenWithLocalName("Message").next(); > if (messageElement == null) { > System.out.println("messageElement jest pusty..."); > } else System.out.println("Message = " + > messageElement.getText()); > } catch (Exception e) { > e.printStackTrace(); > } > } > } > > The error message is at line: > > OMElement result = sender.sendReceive(getSampleTypes); > > Can anyone please help me please? I have no idea what's wrong, because the > SoapUI tool gets the correct results every time, and the client gets > correct > results too, but only when the request is improper.
what do you mean by improper. this service should accept all the XML messages. thanks, Amila. > I tried checking > server's side log, but I couldn't get anything useful from there. > -- > View this message in context: > http://old.nabble.com/org.apache.axis2.AxisFault%3A-unknown-while-calling-working-WebService-tp30661091p30661091.html > Sent from the Axis - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > -- Amila Suriarachchi WSO2 Inc. blog: http://amilachinthaka.blogspot.com/
