Hello,

 

      I'm trying to use axis with the axiom client to connect to a public
web service, these are the information I have on this webservice:

----------------------------------------------------------

POST /webservicedemo/service.asmx HTTP/1.1

Host: www.dagorsoftware.com

Content-Type: text/xml; charset=utf-8

Content-Length: length

SOAPAction: "http://tempuri.org/HelloWho";

 

<?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:Body>

    <HelloWho xmlns="http://tempuri.org/";>

      <firstName>string</firstName>

      <lastName>string</lastName>

    </HelloWho>

  </soap:Body>

</soap:Envelope>

--------------------------------------------------------------

 

This is my class:

 

---------------------------------------------------

package samples.quickstart.clients;

 

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;

 

public class AXIOMClient {

 

    private static EndpointReference targetEPR = new
EndpointReference("http://www.dagorsoftware.com/webservicedemo/service.asmx";
);

 

    public static OMElement sendRequest(String symbol, String price) {

        OMFactory fac = OMAbstractFactory.getOMFactory();

        OMNamespace omNs =
fac.createOMNamespace("http://tempuri.org/HelloWho";, "tns");

 

        OMElement method = fac.createOMElement("HelloWho", omNs);

 

        OMElement value1 = fac.createOMElement("firstName", omNs);

        value1.addChild(fac.createOMText(value1, symbol));

        method.addChild(value1);

 

        OMElement value2 = fac.createOMElement("lastName", omNs);

        value2.addChild(fac.createOMText(value2,price));

        method.addChild(value2);

        return method;

    }

      

    public static void main(String[] args) {

        try {

                  //OMElement getPricePayload = getPricePayload("WSO");

            OMElement updatePayload = sendRequest("WSO", "123.42");

            Options options = new Options();

            options.setTo(targetEPR);

            options.setTransportInProtocol(Constants.TRANSPORT_HTTP);

            ServiceClient sender = new ServiceClient();

            sender.setOptions(options);

                  OMElement result = sender.sendReceive(updatePayload);

                  System.out.println(" result : " +
result.getFirstElement().getText());

 

        } catch (Exception e) {

            e.printStackTrace();

        }

    }

----------------------------------------------------   

 

This is the error I receive:

 

[java] org.apache.axis2.AxisFault: Server did not recognize the value of
HTTP Header SOAPAction: urn:anonOutInOp.

[java]     at
org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:486
)

[java]     at
org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAx
isOperation.java:343)

[java]     at
org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperatio
n.java:389)

[java]     at
org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisO
peration.java:211)

[java]     at
org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)

[java]     at
org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:528)

[java]     at
org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:508)

[java]     at
samples.quickstart.clients.AXIOMClient.main(AXIOMClient.java:59)

[java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

[java]     at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)

[java]     at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)

[java]     at java.lang.reflect.Method.invoke(Method.java:324)

[java]     at
org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217)

[java]     at
org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152)

[java]     at org.apache.tools.ant.taskdefs.Java.run(Java.java:747)

[java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:201)

[java]     at org.apache.tools.ant.taskdefs.Java.execute(Java.java:104)

[java]     at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)

[java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

[java]     at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)

[java]     at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)

[java]     at java.lang.reflect.Method.invoke(Method.java:324)

[java]     at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)

[java]     at org.apache.tools.ant.Task.perform(Task.java:348)

[java]     at org.apache.tools.ant.Target.execute(Target.java:357)

[java]     at org.apache.tools.ant.Target.performTasks(Target.java:385)

[java]     at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)

[java]     at org.apache.tools.ant.Project.executeTarget(Project.java:1298)

[java]     at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.j
ava:41)

[java]     at org.apache.tools.ant.Project.executeTargets(Project.java:1181)

[java]     at org.apache.tools.ant.Main.runBuild(Main.java:698)

[java]     at org.apache.tools.ant.Main.startAnt(Main.java:199)

[java]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)

[java]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)

 

I think I have a problem because I don’t send the value of the header
parameter SOAPAction, but I don’t know where to put this information in my
code.

 

Thank you very much for your help.

 

Best Regards,

 

Cédric Peyruqueou

Reply via email to