You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by 李明洋 <cn...@gmail.com> on 2012/06/28 08:32:22 UTC
Help, Invoking webservice exported by ofbiz fails
*The exported web service is defined as follow:*
<service name="test.add" engine="java" auth="true" export="true"
location="org.aries.erp.test.TestServices"
invoke="add">
<attribute name="a" type="Integer" mode="IN" optional="false"
></attribute>
<attribute name="b" type="Integer" mode="IN"
optional="false"></attribute>
<attribute name="result" type="Integer" mode="OUT"
optional="false"></attribute>
</service>
*the webservice client code is *
public static void main(String[] args) {
Integer output = 0;
String endpoint, username, password;
try{
endpoint = "http://localhost:8080/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("test.add"));
Integer a = 3;
Integer b = 5;
call.addParameter("a", org.apache.axis.Constants.XSD_INT,
javax.xml.rpc.ParameterMode.IN);
call.addParameter("b", org.apache.axis.Constants.XSD_INT,
javax.xml.rpc.ParameterMode.IN);
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.setReturnType(org.apache.axis.Constants.SOAP_INTEGER);
Object response = call.invoke(
new Object[]{
a,
b,
username,
password}
);
output = (Integer) response;
try{
System.out.println(output);
}
catch(Exception e){
e.printStackTrace();
}
}catch(Exception e){
e.printStackTrace();
}
return;
}
but it throws a exception : *org.xml.sax.SAXException: SimpleDeserializer
encountered a child element, which is NOT expected, in something it was
trying to deserialize.*
*
*
Could you give me some help;
thanks
Re: Help, Invoking webservice exported by ofbiz fails
Posted by 李明洋 <cn...@gmail.com>.
it runs. thank you very much :)
2012/6/28 Ankit Jain <an...@gmail.com>
> Instead of using axis as a client it will be easier if you use XMLRPC.
> Here is the link which will help you use XMLRPC.
>
> https://cwiki.apache.org/OFBIZ/using-xmlrpc-as-an-alternative-to-soap.html
>
> Regards,
> Ankit Jain
>
>
>
>
> On Thu, Jun 28, 2012 at 12:02 PM, 李明洋 <cn...@gmail.com> wrote:
>
> > *The exported web service is defined as follow:*
> >
> > <service name="test.add" engine="java" auth="true" export="true"
> > location="org.aries.erp.test.TestServices"
> > invoke="add">
> > <attribute name="a" type="Integer" mode="IN" optional="false"
> > ></attribute>
> > <attribute name="b" type="Integer" mode="IN"
> > optional="false"></attribute>
> > <attribute name="result" type="Integer" mode="OUT"
> > optional="false"></attribute>
> > </service>
> >
> > *the webservice client code is *
> >
> >
> > public static void main(String[] args) {
> > Integer output = 0;
> > String endpoint, username, password;
> > try{
> > endpoint = "
> http://localhost:8080/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("test.add"));
> > Integer a = 3;
> > Integer b = 5;
> > call.addParameter("a", org.apache.axis.Constants.XSD_INT,
> > javax.xml.rpc.ParameterMode.IN);
> > call.addParameter("b", org.apache.axis.Constants.XSD_INT,
> > javax.xml.rpc.ParameterMode.IN);
> > 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.setReturnType(org.apache.axis.Constants.SOAP_INTEGER);
> > Object response = call.invoke(
> > new Object[]{
> > a,
> > b,
> > username,
> > password}
> > );
> > output = (Integer) response;
> > try{
> > System.out.println(output);
> > }
> > catch(Exception e){
> > e.printStackTrace();
> > }
> > }catch(Exception e){
> > e.printStackTrace();
> > }
> > return;
> > }
> >
> > but it throws a exception : *org.xml.sax.SAXException:
> SimpleDeserializer
> > encountered a child element, which is NOT expected, in something it was
> > trying to deserialize.*
> > *
> > *
> > Could you give me some help;
> >
> > thanks
> >
>
Re: Help, Invoking webservice exported by ofbiz fails
Posted by Ankit Jain <an...@gmail.com>.
Instead of using axis as a client it will be easier if you use XMLRPC.
Here is the link which will help you use XMLRPC.
https://cwiki.apache.org/OFBIZ/using-xmlrpc-as-an-alternative-to-soap.html
Regards,
Ankit Jain
On Thu, Jun 28, 2012 at 12:02 PM, 李明洋 <cn...@gmail.com> wrote:
> *The exported web service is defined as follow:*
>
> <service name="test.add" engine="java" auth="true" export="true"
> location="org.aries.erp.test.TestServices"
> invoke="add">
> <attribute name="a" type="Integer" mode="IN" optional="false"
> ></attribute>
> <attribute name="b" type="Integer" mode="IN"
> optional="false"></attribute>
> <attribute name="result" type="Integer" mode="OUT"
> optional="false"></attribute>
> </service>
>
> *the webservice client code is *
>
>
> public static void main(String[] args) {
> Integer output = 0;
> String endpoint, username, password;
> try{
> endpoint = "http://localhost:8080/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("test.add"));
> Integer a = 3;
> Integer b = 5;
> call.addParameter("a", org.apache.axis.Constants.XSD_INT,
> javax.xml.rpc.ParameterMode.IN);
> call.addParameter("b", org.apache.axis.Constants.XSD_INT,
> javax.xml.rpc.ParameterMode.IN);
> 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.setReturnType(org.apache.axis.Constants.SOAP_INTEGER);
> Object response = call.invoke(
> new Object[]{
> a,
> b,
> username,
> password}
> );
> output = (Integer) response;
> try{
> System.out.println(output);
> }
> catch(Exception e){
> e.printStackTrace();
> }
> }catch(Exception e){
> e.printStackTrace();
> }
> return;
> }
>
> but it throws a exception : *org.xml.sax.SAXException: SimpleDeserializer
> encountered a child element, which is NOT expected, in something it was
> trying to deserialize.*
> *
> *
> Could you give me some help;
>
> thanks
>