wsdl java 类区分大小写
在 wsdl 中,我有两种类型,名称相同,大小写不同:LoginResponse 和 LOGINRESPONSE。
如果我使用xfire生成java类,它只生成一个类,LoginResponse, 丢弃 LOGINRESPONSE。
我该如何解决这个问题?
<s:element name="LoginResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="LoginResult" type="tns:LOGINRESPONSE" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="LOGINRESPONSE">
<s:attribute name="Message" type="s:string" />
<s:attribute name="Token" type="s:string" />
<s:attribute name="DataFormat" type="s:string" />
<s:attribute name="Header" type="s:boolean" use="required" />
<s:attribute name="Suffix" type="s:boolean" use="required" />
</s:complexType>
In the wsdl I have 2 types, same name, different cases: LoginResponse and LOGINRESPONSE.
If I use xfire to generate the java classes, it only generates one class, LoginResponse,
discarding the LOGINRESPONSE.
How do I get around this?
<s:element name="LoginResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="LoginResult" type="tns:LOGINRESPONSE" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="LOGINRESPONSE">
<s:attribute name="Message" type="s:string" />
<s:attribute name="Token" type="s:string" />
<s:attribute name="DataFormat" type="s:string" />
<s:attribute name="Header" type="s:boolean" use="required" />
<s:attribute name="Suffix" type="s:boolean" use="required" />
</s:complexType>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
WSDL 中声明的名称确实区分大小写,并且使用仅大小写不同的名称是合法的。然而,这一定是一个坏主意:
当然,从可读性的角度来看,这是一个坏主意。 (我的意思是,如果您正在编写 Java 程序,您不会在同一命名空间中声明变量
acat
和aCat
。您会吗?)虽然 WSDL 是这样的,敏感的编程语言绑定需要将 WSDL 名称映射到不区分大小写的程序标识符(例如,我认为在 Visual Basic 中),或者它们可能会区分大小写,以便生成的标识符符合编程语言的样式约定。无论哪种情况,仅字母大小写不同的 WSDL 名称都会导致问题。
IMO,解决您的问题的最佳长期解决方案是更改 WSDL,这样您就不会出现名称仅因大小写不同的元素、类型等。
Names declared in WSDL are indeed case sensitive, and it is legal to use names that differ only in their case. However, it has to be a bad idea:
Surely, it is a bad idea from the perspective of readability. (I mean, if you were writing a Java program you wouldn't declare variables
acat
andaCat
in the same namespace. Would you?)While WSDL is case sensitive, programming language bindings will need to map WSDL names to case insensitive program identifiers (e.g. in Visual Basic I believe), or they may case mangle them so that the generated identifiers conform to the programming language's style conventions. In either case, WSDL names that differ only in letter case can lead to problems.
IMO the best long term fix for your problem is to change the WSDL so that you don't have elements, types, etc whose names differ only by case.