社区
Web 开发
帖子详情
【webservice】为什么是JAXBElement而不是String类型
yapituy
2009-11-04 04:51:43
wsdl是Axis2生成的,用wsimport根据wsdl生成客户端代码时,LoginInfo类中属性对应的类型不是String类型而是JAXBElement<String>,不知道是什么原因?
...全文
3603
7
打赏
收藏
【webservice】为什么是JAXBElement而不是String类型
wsdl是Axis2生成的,用wsimport根据wsdl生成客户端代码时,LoginInfo类中属性对应的类型不是String类型而是JAXBElement,不知道是什么原因?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
7 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
iloverecenta
2010-03-06
打赏
举报
回复
你用的xfire?
xfire就是这样的,用axis是原始类型
java2G空间仅298元/年 2010年新春特价虚拟主机/服务器促销
全能虚拟主机1G空间/支持asp/php/asp.net3.5/mssql2000/2005/mysql
2010新年高性能比98元/年http://kindinfo.hzxiaoqu.com/info/472.html
Java高性能主机2G空间赠送1G mysql或1G mssql 支持spring/hibernate/struts任意第三方框架 tomcat6独立管理平台
2010新年超值性价比298元/年http://kindinfo.hzxiaoqu.com/info/473.html
雨天的泪1001
2010-03-06
打赏
举报
回复
有没有解决方案啊?
zhangyunyue
2010-01-20
打赏
举报
回复
我也遇到了,哎,这怎么解决啊?有好的办法了吗?
liushurong
2009-12-16
打赏
举报
回复
我也碰到这个问题了
yapituy
2009-11-04
打赏
举报
回复
java类:
package com.example.webservice.beans.xsd;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlType;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "LoginInfo", propOrder = {
"administratorId",
"administratorIdCard",
"administratorMobile",
"administratorName",
"administratorPhone",
"isLogin",
"loginMsg",
"loginTime",
"ofOrganType",
"ofSuperIntendCom",
"organAdd",
"organAreaCode",
"organCnName",
"organInfoId",
"organPhone",
"organPoliceCode",
"organPoliceName",
"peopleInfoId",
"userRights"
})
public class LoginInfo {
@XmlElementRef(name = "administratorId", namespace = "http://beans.webservice.example.com/xsd", type = JAXBElement.class)
protected JAXBElement<String> administratorId;
@XmlElementRef(name = "administratorIdCard", namespace = "http://beans.webservice.example.com/xsd", type = JAXBElement.class)
protected JAXBElement<String> administratorIdCard;
@XmlElementRef(name = "administratorMobile", namespace = "http://beans.webservice.example.com/xsd", type = JAXBElement.class)
protected JAXBElement<String> administratorMobile;
@XmlElementRef(name = "administratorName", namespace = "http://beans.webservice.example.com/xsd", type = JAXBElement.class)
protected JAXBElement<String> administratorName;
@XmlElementRef(name = "administratorPhone", namespace = "http://beans.webservice.example.com/xsd", type = JAXBElement.class)
protected JAXBElement<String> administratorPhone;
protected Boolean isLogin;
@XmlElementRef(name = "loginMsg", namespace = "http://beans.webservice.example.com/xsd", type = JAXBElement.class)
protected JAXBElement<String> loginMsg;
@XmlElementRef(name = "loginTime", namespace = "http://beans.webservice.example.com/xsd", type = JAXBElement.class)
protected JAXBElement<String> loginTime;
@XmlElementRef(name = "ofOrganType", namespace = "http://beans.webservice.example.com/xsd", type = JAXBElement.class)
protected JAXBElement<String> ofOrganType;
@XmlElementRef(name = "ofSuperIntendCom", namespace = "http://beans.webservice.example.com/xsd", type = JAXBElement.class)
protected JAXBElement<String> ofSuperIntendCom;
@XmlElementRef(name = "organAdd", namespace = "http://beans.webservice.example.com/xsd", type = JAXBElement.class)
protected JAXBElement<String> organAdd;
@XmlElementRef(name = "organAreaCode", namespace = "http://beans.webservice.example.com/xsd", type = JAXBElement.class)
protected JAXBElement<String> organAreaCode;
@XmlElementRef(name = "organCnName", namespace = "http://beans.webservice.example.com/xsd", type = JAXBElement.class)
protected JAXBElement<String> organCnName;
@XmlElementRef(name = "organInfoId", namespace = "http://beans.webservice.example.com/xsd", type = JAXBElement.class)
protected JAXBElement<String> organInfoId;
@XmlElementRef(name = "organPhone", namespace = "http://beans.webservice.example.com/xsd", type = JAXBElement.class)
protected JAXBElement<String> organPhone;
@XmlElementRef(name = "organPoliceCode", namespace = "http://beans.webservice.example.com/xsd", type = JAXBElement.class)
protected JAXBElement<String> organPoliceCode;
@XmlElementRef(name = "organPoliceName", namespace = "http://beans.webservice.example.com/xsd", type = JAXBElement.class)
protected JAXBElement<String> organPoliceName;
@XmlElementRef(name = "peopleInfoId", namespace = "http://beans.webservice.example.com/xsd", type = JAXBElement.class)
protected JAXBElement<String> peopleInfoId;
@XmlElementRef(name = "userRights", namespace = "http://beans.webservice.example.com/xsd", type = JAXBElement.class)
protected JAXBElement<String> userRights;
public JAXBElement<String> getAdministratorId() {
return administratorId;
}
public void setAdministratorId(JAXBElement<String> value) {
this.administratorId = ((JAXBElement<String> ) value);
}
public JAXBElement<String> getAdministratorIdCard() {
return administratorIdCard;
}
public void setAdministratorIdCard(JAXBElement<String> value) {
this.administratorIdCard = ((JAXBElement<String> ) value);
}
public JAXBElement<String> getAdministratorMobile() {
return administratorMobile;
}
public void setAdministratorMobile(JAXBElement<String> value) {
this.administratorMobile = ((JAXBElement<String> ) value);
}
public JAXBElement<String> getAdministratorName() {
return administratorName;
}
public void setAdministratorName(JAXBElement<String> value) {
this.administratorName = ((JAXBElement<String> ) value);
}
public JAXBElement<String> getAdministratorPhone() {
return administratorPhone;
}
public void setAdministratorPhone(JAXBElement<String> value) {
this.administratorPhone = ((JAXBElement<String> ) value);
}
public Boolean isIsLogin() {
return isLogin;
}
public void setIsLogin(Boolean value) {
this.isLogin = value;
}
public JAXBElement<String> getLoginMsg() {
return loginMsg;
}
public void setLoginMsg(JAXBElement<String> value) {
this.loginMsg = ((JAXBElement<String> ) value);
}
public JAXBElement<String> getLoginTime() {
return loginTime;
}
public void setLoginTime(JAXBElement<String> value) {
this.loginTime = ((JAXBElement<String> ) value);
}
public JAXBElement<String> getOfOrganType() {
return ofOrganType;
}
public void setOfOrganType(JAXBElement<String> value) {
this.ofOrganType = ((JAXBElement<String> ) value);
}
public JAXBElement<String> getOfSuperIntendCom() {
return ofSuperIntendCom;
}
public void setOfSuperIntendCom(JAXBElement<String> value) {
this.ofSuperIntendCom = ((JAXBElement<String> ) value);
}
public JAXBElement<String> getOrganAdd() {
return organAdd;
}
public void setOrganAdd(JAXBElement<String> value) {
this.organAdd = ((JAXBElement<String> ) value);
}
public JAXBElement<String> getOrganAreaCode() {
return organAreaCode;
}
public void setOrganAreaCode(JAXBElement<String> value) {
this.organAreaCode = ((JAXBElement<String> ) value);
}
public JAXBElement<String> getOrganCnName() {
return organCnName;
}
public void setOrganCnName(JAXBElement<String> value) {
this.organCnName = ((JAXBElement<String> ) value);
}
public JAXBElement<String> getOrganInfoId() {
return organInfoId;
}
public void setOrganInfoId(JAXBElement<String> value) {
this.organInfoId = ((JAXBElement<String> ) value);
}
public JAXBElement<String> getOrganPhone() {
return organPhone;
}
public void setOrganPhone(JAXBElement<String> value) {
this.organPhone = ((JAXBElement<String> ) value);
}
public JAXBElement<String> getOrganPoliceCode() {
return organPoliceCode;
}
public void setOrganPoliceCode(JAXBElement<String> value) {
this.organPoliceCode = ((JAXBElement<String> ) value);
}
public JAXBElement<String> getOrganPoliceName() {
return organPoliceName;
}
public void setOrganPoliceName(JAXBElement<String> value) {
this.organPoliceName = ((JAXBElement<String> ) value);
}
public JAXBElement<String> getPeopleInfoId() {
return peopleInfoId;
}
public void setPeopleInfoId(JAXBElement<String> value) {
this.peopleInfoId = ((JAXBElement<String> ) value);
}
public JAXBElement<String> getUserRights() {
return userRights;
}
public void setUserRights(JAXBElement<String> value) {
this.userRights = ((JAXBElement<String> ) value);
}
}
yapituy
2009-11-04
打赏
举报
回复
wsdl:第二部分
<wsdl:message name="adminLoginRequest">
<wsdl:part name="parameters" element="ns1:adminLogin"/>
</wsdl:message>
<wsdl:message name="adminLoginResponse">
<wsdl:part name="parameters" element="ns1:adminLoginResponse"/>
</wsdl:message>
<wsdl:message name="loginRequest">
<wsdl:part name="parameters" element="ns1:login"/>
</wsdl:message>
<wsdl:message name="loginResponse">
<wsdl:part name="parameters" element="ns1:loginResponse"/>
</wsdl:message>
<wsdl:message name="logoutRequest">
<wsdl:part name="parameters" element="ns1:logout"/>
</wsdl:message>
<wsdl:message name="logoutResponse">
<wsdl:part name="parameters" element="ns1:logoutResponse"/>
</wsdl:message>
<wsdl:portType name="LoginManagePortType">
<wsdl:operation name="adminLogin">
<wsdl:input message="ns1:adminLoginRequest" wsaw:Action="urn:adminLogin"/>
<wsdl:output message="ns1:adminLoginResponse" wsaw:Action="urn:adminLoginResponse"/>
</wsdl:operation>
<wsdl:operation name="login">
<wsdl:input message="ns1:loginRequest" wsaw:Action="urn:login"/>
<wsdl:output message="ns1:loginResponse" wsaw:Action="urn:loginResponse"/>
</wsdl:operation>
<wsdl:operation name="logout">
<wsdl:input message="ns1:logoutRequest" wsaw:Action="urn:logout"/>
<wsdl:output message="ns1:logoutResponse" wsaw:Action="urn:logoutResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="LoginManageSOAP11Binding" type="ns1:LoginManagePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="adminLogin">
<soap:operation soapAction="urn:adminLogin" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="login">
<soap:operation soapAction="urn:login" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="logout">
<soap:operation soapAction="urn:logout" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="LoginManageSOAP12Binding" type="ns1:LoginManagePortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="adminLogin">
<soap12:operation soapAction="urn:adminLogin" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="login">
<soap12:operation soapAction="urn:login" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="logout">
<soap12:operation soapAction="urn:logout" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="LoginManageHttpBinding" type="ns1:LoginManagePortType">
<http:binding verb="POST"/>
<wsdl:operation name="adminLogin">
<http:operation location="LoginManage/adminLogin"/>
<wsdl:input>
<mime:content type="text/xml" part="adminLogin"/>
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="adminLogin"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="login">
<http:operation location="LoginManage/login"/>
<wsdl:input>
<mime:content type="text/xml" part="login"/>
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="login"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="logout">
<http:operation location="LoginManage/logout"/>
<wsdl:input>
<mime:content type="text/xml" part="logout"/>
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="logout"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="LoginManage">
<wsdl:port name="LoginManageSOAP11port_http" binding="ns1:LoginManageSOAP11Binding">
<soap:address location="http://10.160.11.5:8080/crjout/services/LoginManage"/>
</wsdl:port>
<wsdl:port name="LoginManageSOAP12port_http" binding="ns1:LoginManageSOAP12Binding">
<soap12:address location="http://10.160.11.5:8080/crjout/services/LoginManage"/>
</wsdl:port>
<wsdl:port name="LoginManageHttpport" binding="ns1:LoginManageHttpBinding">
<http:address location="http://10.160.11.5:8080/crjout/services/LoginManage"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
yapituy
2009-11-04
打赏
举报
回复
wsdl:第一部分
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ns0="http://loginmanage.example.com/xsd" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:ns1="http://loginmanage.example.com" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:ns2="http://beans.webservice.example.com/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://loginmanage.example.com">
<wsdl:documentation>LoginManage</wsdl:documentation>
<wsdl:types>
<xs:schema xmlns:ax211="http://loginmanage.example.com/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://loginmanage.example.com/xsd">
<xs:complexType name="AdminLoginInfo">
<xs:sequence>
<xs:element minOccurs="0" name="isLogin" type="xs:boolean"/>
<xs:element minOccurs="0" name="loginMsg" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<xs:schema xmlns:ns="http://loginmanage.example.com" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://loginmanage.example.com">
<xs:element name="adminLogin">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="usbKey" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="password" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="machineCode" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="adminLoginResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="ns0:AdminLoginInfo"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="login">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="usbKey" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="password" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="machineCode" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="clientVersion" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="loginResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="ns2:LoginInfo"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="logout">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="usbKey" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="logoutResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<xs:schema xmlns:ax212="http://beans.webservice.example.com/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://beans.webservice.example.com/xsd">
<xs:complexType name="LoginInfo">
<xs:sequence>
<xs:element minOccurs="0" name="administratorId" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="administratorIdCard" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="administratorMobile" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="administratorName" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="administratorPhone" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="isLogin" type="xs:boolean"/>
<xs:element minOccurs="0" name="loginMsg" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="loginTime" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="ofOrganType" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="ofSuperIntendCom" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="organAdd" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="organAreaCode" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="organCnName" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="organInfoId" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="organPhone" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="organPoliceCode" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="organPoliceName" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="peopleInfoId" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="userRights" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
关于cxf生成客户端代码中的
JAXB
Element
<
String
>
本文解释了在使用CXF或X-Fire进行
Webservice
开发时,如何处理
JAXB
Element
<
String
>
类型
的问题。当服务器端WSDL文件包含nillable=true属性时,客户端代码将使用
JAXB
Element
而非直接使用
String
类型
。文中提供了两种有效的赋值方法,并强调了正确使用QName的重要性。
wsdl2java
jaxb
element
<
string
> instead of
string
本文介绍如何通过自定义binding文件解决使用cxf的wsdl2java插件生成的Java类中出现不期望的
JAXB
Element
类型
问题。通过配置-b参数及my_binding.xml文件,可以避免
String
等简单
类型
被包装成
JAXB
Element
。
关于
webservice
客户端生成代码中的
JAXB
Element
字段
类型
的解决办法
本文介绍了解决
Webservice
客户端代码中
JAXB
Element
字段
类型
赋值问题的方法。包括修改生成代码使其变为
String
类型
,以及如何直接对
JAXB
Element
进行赋值。提供两种赋值方法,帮助开发者有效处理服务器端WSDL文件中带有nillable属性的问题。
wsdl2java/soapUI将
JAXB
Element
转为
String
本文介绍了在使用CXF或x-Fire开发
WebService
时遇到
JAXB
Element
类型
转换为
String
的问题。详细讨论了解决方案,包括创建XML文件以辅助转换,并提供了两种在soapUI和wsdl2java中操作的方法,以及不转换为
String
时的赋值方式。
webservice
客户端不生成
JAXB
Element
类型
本文介绍了一种在MyEclipse中根据wsdl文件生成
WebService
代码的方法,避免生成
JAXB
Element
类型
,提高代码的易用性。通过创建特定配置文件并使用wsimport工具,可以定制化生成所需的Java代码。
Web 开发
81,111
社区成员
341,727
社区内容
发帖
与我相关
我的任务
Web 开发
Java Web 开发
复制链接
扫一扫
分享
社区描述
Java Web 开发
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章