简体   繁体   English

如何将我的java变量设置为具有xsi:type

[英]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. 我有一个Web应用程序,需要调用Web服务来处理某些事情。 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. 但是,给定的客户端代码为jar文件格式。 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. 给出的客户端代码不是最新的,这意味着我使用的客户端代码实际上与实际的Web服务不匹配。

This is part of my wsdl that I use to fire to web service through SOAP UI: 这是wsdl的一部分,我使用它通过SOAP UI触发Web服务:

<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: 当我使用SOAP UI在给定的wsdl上启动到Web服务时,它将引发以下错误:

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. 因此,我联系Web服务人员,并告诉他们我想要最新的客户端代码。 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: 他们只是要求我自己更改wsdl,如下所示:

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

Its work on SOAP UI call. 它在SOAP UI调用上的工作。

However, now I want to code it in java, I just use the given client code to set the value: 但是,现在我想用Java对其进行编码,我只是使用给定的客户端代码来设置值:

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? 当从应用程序调用Web服务时,我可以用Java代码编写什么以使其具有xsi:type="xsd:string"

If you have the WSDL you can generate the Java code. 如果您拥有WSDL,则可以生成Java代码。 This method of generating code is called top down web services development. 这种生成代码的方法称为自上而下的Web服务开发。

If you are using Maven have a look at this question on java code from wsdl 如果您使用的是Maven,请查看wsdl中有关Java代码的问题

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: 如果您使用的是Eclipse,则还可以通过选择新的Web服务客户端作为项目类型来从WSDL创建新的Web服务客户端,请参见以下屏幕快照:

在此处输入图片说明

You then add the WSDL to the next dialog and follow the steps through to the end.See screen shot below: 然后将WSDL添加到下一个对话框中,并按照步骤进行操作,请参见下面的屏幕快照:

在此处输入图片说明

Netbeans and other IDE's would also allow you to generate java classes from WSDL. Netbeans和其他IDE还将允许您从WSDL生成Java类。 Maven is nice as it works in all IDE's. Maven很不错,因为它可以在所有IDE中使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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