How to Call Soap Service from Ofbiz .

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to Call Soap Service from Ofbiz .

xiongbk
Hi all,
I want to call soap service from Ofbiz. But i have try some way but not sucessfull.
1. I try to call by Service Stub
---------------------------------------------------Code-------------------------------------------
    public static void main(String[] args) {
        try {
            //  URL url = new URL(                    "http://127.0.0.1:1234/webtools/control/SOAPService/searchHelloPerson");
            //http://demo-trunk.ofbiz.apache.org/webtools/control/SOAPService/getOrderStatus
            URL url = new URL(
                    "http://localhost:8080/webtools/control/SOAPService/testScv/");
            TestScvSoapBindingStub stub = new
                                          TestScvSoapBindingStub(
                                                  url, null);
//            stub.setPassword("ofbiz");
//            stub.setUsername("admin");

            MapEntry Entry = new MapEntry();
            // message -- defaultValue--
            StdString key1 = new StdString("defaultValue");
            StdDouble value1 = new StdDouble(123456);
            MapKey key = new MapKey(key1);
            MapValue mapValue = new MapValue();
            mapValue.setStdDouble(value1);
            Entry.setMapKey(key);
            Entry.setMapValue(mapValue);

            MapEntry user = buildEntry("login.username", "admin");
            MapEntry pass = buildEntry("login.password", "ofbiz");
            MapEntry message = buildEntry("message", "HungVM Test");
            MapMap map = new MapMap();
            MapEntry[] hung = new MapEntry[4];
            hung[0] = Entry;
            hung[1] = message;
            hung[2] = user;
            hung[3] = pass;
            map.setMapEntry(hung);
            MapMapHolder mapHolder = new MapMapHolder(map);
            stub.testScv(mapHolder);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
---------------------------------------------------Error-------------------------------------------

org.xml.sax.SAXException: Invalid element in org.apache.ofbiz.service.MapMap - map-Entry
        at org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeserializer.java:258)
        at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
        at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
        at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
        at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
        at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
        at org.apache.axis.client.Call.invoke(Call.java:2467)
        at org.apache.axis.client.Call.invoke(Call.java:2366)
        at org.apache.axis.client.Call.invoke(Call.java:1812)
        at org.apache.ofbiz.service.TestScvSoapBindingStub.testScv(TestScvSoapBindingStub.java:253)
        at org.apache.ofbiz.service.test.main(test.java:69)


2. I try call by way
---------------------------------------------------Code-------------------------------------------

  endpoint = "http://localhost:1234/webtools/control/SOAPService/";
            username = "admin";
            password = "ofbiz";
            Call call = (Call)new Service().createCall();
            call.setTargetEndpointAddress(new URL(endpoint));
            call.setOperationName(new javax.xml.namespace.QName(
                    "getOrderStatus", "getOrderStatus"));
            call.addParameter("login.username",
                              org.apache.axis.Constants.XSD_STRING,
                              javax.xml.rpc.ParameterMode.IN);
            call.addParameter("login.password",
                              org.apache.axis.Constants.XSD_STRING,
                              javax.xml.rpc.ParameterMode.IN);
            call.addParameter("statusId", org.apache.axis.Constants.XSD_STRING,
                              javax.xml.rpc.ParameterMode.IN);
            call.setReturnType(org.apache.axis.Constants.SOAP_STRING);
            Object response = call.invoke(new Object[] {"admin", "ofbiz",
                                          inputParam});
            output = (String) response;
---------------------------------------------------Error-------------------------------------------
org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
        at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:145)
        at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
        at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
        at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
        at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
        at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
        at org.apache.axis.client.Call.invoke(Call.java:2467)
        at org.apache.axis.client.Call.invoke(Call.java:2366)
        at org.apache.axis.client.Call.invoke(Call.java:1812)
        at org.apache.ofbiz.service.test.ServiceCall(test.java:130)
        at org.apache.ofbiz.service.test.main(test.java:71)



Ps, give me a advice.
thanks
Reply | Threaded
Open this post in threaded view
|

Re: How to Call Soap Service from Ofbiz .

invincible
Hi xiongBK,

I am facing the same problem..i have tried all those methods without success.
could you please help me out here. How did you finally call this service ??

Thanks in advance.
Reply | Threaded
Open this post in threaded view
|

Re: How to Call Soap Service from Ofbiz .

lintch
Have you found the solution ?
Reply | Threaded
Open this post in threaded view
|

Re: How to Call Soap Service from Ofbiz .

Paul Foxworthy
Hi lintch,

Have you looked at the discussion at https://cwiki.apache.org/OFBIZ/export-ofbiz-services-that-use-complex-type-parameters-via-soap-using-axis2-r892712.html ?

That might help.

Cheers

Paul Foxworthy

lintch wrote
Have you found the solution ?
--
Coherent Software Australia Pty Ltd
http://www.coherentsoftware.com.au/

Bonsai ERP, the all-inclusive ERP system
http://www.bonsaierp.com.au/
Reply | Threaded
Open this post in threaded view
|

Re: How to Call Soap Service from Ofbiz .

Deepak
In reply to this post by xiongbk