Using complex data types from Java in Axis webservice

I am currently developing a Java app which handles a SOAP webservice.

The problem lies after I parse the WSDL [the Parser object from Apache Axis does it for me], and I create the call.

When I try to invoke it, I have to pass a Object[] to assign the parameters [taken from the Action of the WSDL]. A normal action is easy, but when I have custom datatypes, I can't get it to fill it out for me. I try to pass Object[]{ new Object { }}, but it assigns the first field instead. I can't pass it already processed, because it changes the '< >' to '--lt --gt', and the server doesn't recognize it'.

This is a fragment of the WSDL.

  <s:element name="FERecuperaQTYRequest">
        <s:element minOccurs="0" maxOccurs="1" name="argAuth" type="tns:FEAuthRequest" />
  <s:complexType name="FEAuthRequest">
      <s:element minOccurs="0" maxOccurs="1" name="Token" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="Sign" type="s:string" />
      <s:element minOccurs="1" maxOccurs="1" name="cuit" type="s:long" />

And this is the troublesome Java Fragment

        QTY = (String) call.invoke (
                new Object[]{
                     new Object[]{
                            tokenConexion.getToken (),
                            tokenConexion.getSign (),
                            tokenConexion.getCUIT ()

Asked by: Anna410 | Posted: 28-01-2022

Answer 1

Have you looked into using something like Spring's proxy functionality? You tell it a bit about the webservice in a spring config file, and all your client code has to deal with is an interface that you create - it doesn't even have to know that there is a web service on the other side!

Example Spring config:

<bean id="myService" class="org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean">
    <property name="serviceFactoryClass" value="org.apache.axis.client.ServiceFactory"/>
    <property name="wsdlDocumentUrl" value="classpath://META-INF/myService.wsdl"/>
    <property name="namespaceUri" value="http://com/myService"/>
    <property name="endpointAddress" value="http://server/MyService"/>
    <property name="serviceName" value="MyService"/>
    <property name="portName" value="MyService"/>
    <property name="serviceInterface" value="com.IMyService"/>
    <property name="lookupServiceOnStartup" value="false"/>
<bean id="myClient" class="com.MyServiceClient">
    <property name="myService" ref="myService"/>


public interface IMyService {
    Foo getFoo();

public class MyServiceClient {
    private IMyService myService;
    public void setMyService(IMyService myService) {
        this.myService = myService;

    public void DoStuff() {
        Foo foo = myService.getFoo();

For custom objects, you may need to subclass JaxRpcPortProxyFactoryBean:

public class MyServiceFactoryBean extends JaxRpcPortProxyFactoryBean {
protected void postProcessJaxRpcService(Service service) {
    TypeMappingRegistry registry = service.getTypeMappingRegistry();
    TypeMapping mapping = registry.createTypeMapping();
            QName qName = new QName("http://com/myService", "Foo");
    mapping.register(Foo.class, qName,
            new BeanSerializerFactory(Foo.class, qName),
            new BeanDeserializerFactory(Foo.class, qName));

What I love about this is that code that shouldn't care about the implementation of the service doesn't. Testing becomes a breeze, and the cohesion of your classes is much better.

Answered by: Dainton954 | Posted: 01-03-2022

Answer 2

We tried to use complex objects and Axis. Don't! We had a bunch of problems with Dotnet being able to create a correct object from the WSDL. We ended up just using primitives, strings, and arrays. If someone has a good method of using complex object I would love to hear it.

Answered by: Catherine958 | Posted: 01-03-2022

Similar questions

web services - Expose Java class as SOAP WebService - how?

Closed. This question does not meet Stack Overflow guid...

web services - Java: using endpoint to publish webservice to tomcat server

i am creating a simple SOAP web service. i am to ensure that it runs on a tomcat web service. im trying to implement this with JAX-WS (see code) my question is: does the Endpoint.publish use the tomcat server to host this or is it a mini glassfish kind of server? should i be extending UnicastRemoveObject or something similiar instead? ideally it would be able to be packaged into a .WAR and...

web services - get client IP for webservice on java 6 embbeded http server

I am implementing web service on java 6 weight light (embbeded) HTTP server jax-ws-web-services-without-java-ee-containers - for testing purposes - I want to get the client IP for each request. I tried to declare web service context in my web service class: @Resource W...

web services - Can't consume webservice from Java

I created the webservice stubs using axis2-1.5's wsdl2java.bat. This created a src folder with the following structure in it: src/net/mycompany/www/services/ The package of the file is: package; Now, I am trying to use this stub in my java code. I placed my java file in the same services folder. I set the...

web services - Java Webservice with generic methods

I was wondering if it is possible to make a generic webservice method in java like this: @WebMethod public &lt;T extends Foo&gt; void testGeneric(T data){ However when I try to consume this with a Java client I get an error stating: [ERROR] Schema descriptor {http://####/}testGeneric in message part "parameters" is not defined an...

web services - java webservice - wsgen

I've got a task to create a webservice for school. The problem is for some reason I won't get wsgen to work correctly. I've got a class named Warehouse, which is in the package: com.horstmann.corejava. Now I build this project named Warehouse, and after this I go into commandprompt(cmd) and type "cd C:\Program Files (x86)\Java\jdk1.6.0_20\bin" where wsgen.exe is. Next line I type is: "wsgen -cd C:\Users\Jul...

web services - Java RMI via Webservice?

I'm searching for a possibility to run a java RMI application via webservice or an internet protocol. is there any framework or solution that says "I can run RMI as WebService with WS-Security" or "I can run RMI via HTTPS" etc. or is tunneling RMI over HTTP or SSH the only way?

web services - Vector of Vector in a Java webservice

I am writing a webservice method to return the values of a table.I am using two Vectors one for the column and another for the values of the table.The Vector used for Values of the table contain each row as a Vector.These methods are written inside an EJB and the webservice is deployed in Weblogic 10.3. I am able to hit the webservice and call the methods and able to fetch the columnnames Vector.However when I fetch the va...

web services - Can I change the Java package of a WebService Client?

So, my JAVA application is connected to different WebServices that were developed inhouse and all 3 of them are packaged under org.tempuri This is the default namespace I believe and when the wizard creates the Java packages it places them under org.tempuri.. I wanted to change them to give them meaningful names but then my app exploded :( Can I just go into the .wsdl and change the namespace and repackage ...

web services - Java Webservice URL in JSF

I created a JSF application which also offers some Webservices. The webservices are created via annotations. Now I want to create a webserviceInfo.xhtml Page , where I get all the needed webservice Information. When I go to the address, I get all the information needed to access the webservice (this info page is generated automatically by ...

web services - Expose Java class as SOAP WebService - how?

Closed. This question does not meet Stack Overflow guid...

java - Generated equals in Webservice Stub

All the generated webservice-stubs from our backend have an equals-method similar to this one: private java.lang.Object __equalsCalc = null; public synchronized boolean equals(java.lang.Object obj) { if (!(obj instanceof PropertyData)) return false; PropertyData other = (PropertyData) obj; if (obj == null) return false; if (this == obj) return true; if (__equalsCalc != null) { re...

java - Eclipse plugin for Apache Axis2 to create webservice

please give me the link to download plugins for apache axis, i tried in some sites but the link was not current so i was not able to download. thanks in advance, Mahesh

java - Adding fields to a WebService

I have a SOAP service that exposes a method TradeDetail getTradeDetail() TradeDetail stores 5 fields, transaction number, dates etc I need to add a couple of fields to TradeDetail. I want to keep backward compatibility (for a while) and it looks as if my options are limited to creating a new class with the extra fields TradeDetail2 getTradeDetail2()

java - How to abort the call to webservice at both client and server end?

I can abort the web service call from client by calling ABORT method of web service proxy. However at server where web service is hosted, the call only ends when it completes the processing. As server doesn’t expect any other inputs related to already called web method while processing it, I am not able to close it from client. Is there any way I can also abort the call at server i.e. stop the large calc...

Java Webservice and .NET client dropping DateTime objects

Seeing something strange between a Java web service and the .NET client talking to it. We are sending an object back and forth with a DateTime property on it. Sort of like this (generated from the WSDL): [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCa...

Construct a SOAP Request to a WebService using Axis2 Library in Java?

I need to be able to construct a SOAP request using Apache Axis2 and provide the IP address and user agent in the SOAP header to the webservice. Is there a code sample that describes how to do that? Thanks in advance for the help! Best wishes Ruchi Kaur.

java - How to call a web service from within a webservice

I am trying to create a web service which is a consumer to another webservice. Here is the layout. I developed a Java class and created a webservice out of it. Then I used Eclipse tools to generate a client side stub and other files. I packed these files in a jar and used it in another project. I tested the files in the jar I was able to access the first webservice. Now I created another w...

c# - Library to create java stubs for webservice

I would like to know if anyone can recommend a good library to generate java webservices stubs as clients. Currently I'm using a product which has embedded a generator which only needs the WSDL and then creates the needed classes and methods. My problems is it throws warnings and doesn't create any method for some webservices I'm trying to use. The real problem is it doesn't explain what the pro...

java - Why does a webservice specify all request and response types as a string?

I am working with a legacy webservice, and they supplied us their WSDL to work with. Now my problem is, that every function specifies the same argument and return type. And this type is then specified as being string! Example: &lt;definitions targetNamespace="java:the.custom.namespace" xmlns="" xmlns:tns="java:the.custom.namespace" xmlns:xsi=...

Still can't find your answer? Check out these amazing Java communities for help...

Java Reddit Community | Java Help Reddit Community | Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)