Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Top-down Web Service Generation using AXIS1 is taking my complexType apart

When I generate a stub (using Eclipse Oxygen, top-down, Axis1), the function are generated like these:

public TokenNamespace.ideas.mace.TokenResponse getToken(TokenNamespace.ideas.mace.TokenRequest tokenRequest) throws java.rmi.RemoteException {
    return null;
}

public TokenNamespace.ideas.mace.TokenResponse getToken2(TokenNamespace.ideas.mace.TokenRequest tokenRequest, boolean stopOnAnyError, TokenNamespace.ideas.mace.EACommand[] command, TokenNamespace.ideas.mace.HttpHeader[] httpHeader) throws java.rmi.RemoteException {
    return null;
}

Why is TokenRequest class kept intact, while BatchCommand and HttpHeaders are dismantled?

I tried adding more sub-elements under HttpHeaders and BatchCommand, but they just get split up as additional parameters. I can't spot any difference between their declarations and getToken's.

like image 388
KC Wong Avatar asked Nov 24 '17 03:11

KC Wong


1 Answers

If you are talking about getToken2() method then actually they are not dismantled rather if you see httpheaders is actually an array of httpheader so in java code it is converted to an array of httpheaders as parameter to getToken2 and same is the case for the CommandBatch.

And

If you are talking about why they are dismantled from getToken() method then the solution is as given below.

This is because in the wsdl file you have not defined the parameters for getToken() method

For example you have this

<portType name="TokenService">
        <operation name="getToken" parameterOrder="getToken">
            <input message="tns:TokenService_getToken" />
            <output message="tns:TokenService_getTokenResponse" />
        </operation>
        <operation name="getToken2" parameterOrder="getToken batchCommand httpHeaders">
            <input message="tns:TokenService_getToken2" />
            <output message="tns:TokenService_getTokenResponse" />
        </operation>
    </portType>

You should update it like below

<portType name="TokenService">
        <operation name="getToken" parameterOrder="getToken batchCommand httpHeaders">
            <input message="tns:TokenService_getToken" />
            <output message="tns:TokenService_getTokenResponse" />
        </operation>
        <operation name="getToken2" parameterOrder="getToken batchCommand httpHeaders">
            <input message="tns:TokenService_getToken2" />
            <output message="tns:TokenService_getTokenResponse" />
        </operation>
    </portType>

That is your operation getToken should define the required parameters in the parameterOrder attribute.

And also change the message from

<message name="TokenService_getToken">
        <part element="tns:httpHeaders" name="httpHeaders" />
    </message>

to

<message name="TokenService_getToken">
        <part element="tns:getToken" name="getToken" />
        <part element="tns:batchCommand" name="batchCommand" />
        <part element="tns:httpHeaders" name="httpHeaders" />
    </message>

After that it generates the code correctly.

You can further take a look at this answer It is explaining how maxOccurs attribute is used. If it is not specified then an element will occur only once. So that is why getToken has not been changed into an array like the other parameters and rather replaced by the one occurrence of the TokenRequest which is indeed what is contained within getToken complexType. That is a single occurrence of TokenRequest

like image 96
muasif80 Avatar answered Oct 24 '22 05:10

muasif80