简体   繁体   中英

how to set my java variable to have xsi:type

I have a web application that need to call a web service to process something. As usual, I ask for the client code from client, so that I can code base on the client code.

However, the given client code is in jar file format. Thus I just really change on it. I just can call it.

Now I have some problem. The client code given is not up to date, which means, the client code I use, is actually not match with the real web services.

This is part of my wsdl that I use to fire to web service through SOAP UI:

<attributeSet>
            <!--Zero or more repetitions:-->
            <attributes>
               <value>mmm</value>
               <attributeID>DP</attributeID>
            </attributes>
         </attributeSet>

When I use SOAP UI to fire to the web service base on the given wsdl, it will throw me error as follow:

AttributeSet::validateFieldType (Field 'Password Format' (Field ID 30), data type 'STRING' (Type ID 1), Field value '0', Attribute set Credentials)

Thus, I contact the web service person, and tell them I want the latest client code. But, due to some technical problem at their site, they unable to provide the latest client code to us. And they just ask me to change the wsdl myself as follow:

<attributeSet>
            <!--Zero or more repetitions:-->
            <attributes>
               <value xsi:type="xsd:string">m</value>
               <attributeID>DP</attributeID>
            </attributes>
         </attributeSet>

Its work on SOAP UI call.

However, now I want to code it in java, I just use the given client code to set the value:

ca1.setAttributeID("DP");
ca1.setValue("m");

What can I code in java code, to make it have the xsi:type="xsd:string" when do web service call from application?

If you have the WSDL you can generate the Java code. This method of generating code is called top down web services development.

If you are using Maven have a look at this question on java code from wsdl

If you are using Eclipse you can also create a new web service client from WSDL by choosing a new web service client as a project type see screen shot below:

在此处输入图片说明

You then add the WSDL to the next dialog and follow the steps through to the end.See screen shot below:

在此处输入图片说明

Netbeans and other IDE's would also allow you to generate java classes from WSDL. Maven is nice as it works in all IDE's.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM