FarHooD
FarHooD

Reputation: 67

Jax-ws in java change return tag into result

Hi I have this type of return :

<?xml version="1.0" encoding="UTF-8"?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Header/>
    <S:Body xmlns:ns2="http://point.modam.webservice.megnatis.ir.mehritco/">
        <ns2:MeterInstantParameterParamResponse>
            <return>
                <MeterInstantParameter>
                    <V_A>11753.95</V_A>
                    <V_B>0.0</V_B>
                    <V_C>0.0</V_C>
                    <MTime>2020-10-02T07:00:12.0000000</MTime>
                    <ES>false</ES>
                </MeterInstantParameter>
<MeterInstantParameter>
...
</MeterInstantParameter>
<message/>
                <error>Successfully</error>
            </return>
        </ns2:MeterInstantParameterParamResponse>
    </S:Body>
</S:Envelope>

And I need Changed to exactly Like :

<?xml version="1.0" encoding="UTF-8"?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Header/>
    <S:Body xmlns:ns2="http://point.modam.webservice.megnatis.ir.mehritco/">
        <ns2:MeterInstantParameterParamResponse>
<a:Result>
                    <a:MeterInstantParameter>
                        
                        <a:MTime>2020-12-27T08:45:00.7266711</a:MTime>
                        <a:V_A>19920.380000</a:V_A>
                        <a:V_B>20066.930000</a:V_B>
                        <a:V_C>20117.800000</a:V_C>
                    </a:MeterInstantParameter>
...
<a:Result>
...

I have Two Issue I think or maybe I think! one the the tag of return need to change And be like <a:Result>. two I don't know what is (a:) and how I can added to my bean , I don't want to change variables names in the bean class. So what must I do for correct my result like the one I need?

Upvotes: 0

Views: 648

Answers (1)

Tian Claassens
Tian Claassens

Reputation: 26

To Change you need to specify a WebResult

So you can do something like :

@WebMethod(operationName = "Method")
 
@WebResult(name="Result")
    public Result Method(@WebParam(name = "input") String param) {
...
    }

Props to this answer : Java Webservices and SOAP - Changing an element name

Upvotes: 1

Related Questions