SOAP Webサービスを使用するアプリケーションで作業しています。 CXFを使用してWebサービスのWSDLからスタブを作成しました。CXF + Java:xmlns属性を削除するには
リクエストの要素の一つは次のようになります。私は全体の要求を作成しています私のアダプタクラスでは、
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name="FolderDetailsType", namespace="http://newyorklife.com/services/businessdomain/distributionmanagement/maintenance/maintenancerequestsresponses", propOrder={"any"})
public class FolderDetailsType
implements Serializable
{
private static final long serialVersionUID = -6026937020915831338L;
@XmlAnyElement
protected List<Element> any;
public FolderDetailsType() {}
public List<Element> getAny()
{
if (this.any == null) {
this.any = new ArrayList();
}
return this.any;
}
}
、私は名前を「businessTypeCode」を持つ要素を作成し、それを追加してい要素のリストCXFが要求XMLを生成するとき
FolderDetailsType folderDetails = new FolderDetailsType();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance().newDocumentBuilder()
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element businessTypeCode = document.createElement("BusinessTypeCd");
businessTypeCode.setAttribute("code", requestMetadata.getBusinessTypeCode());
folderDetails.getAny().add(businessTypeCode);
、それは以下のようになります。
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<ns21:InsertBusinessDocumentRequest xmlns="http://services/businessdomain/distributionmanagement/maintenance/maintenancerequestsresponses" xmlns:ns10="http://schemas/framework/exceptionentry" xmlns:ns11="http://schemas/framework/systemexception" xmlns:ns12="http://schemas/cim/claim/deathclaim" xmlns:ns13="http://schemas/cim/financialcontract/contract" xmlns:ns14="http://schemas/cim/common/name" xmlns:ns15="http://schemas/framework/baserequest" xmlns:ns16="http://schemas/framework/severity" xmlns:ns17="http://schemas/framework/systemexceptionlocation" xmlns:ns18="http://schemas/framework/status" xmlns:ns19="http://schemas/framework/businessexception" xmlns:ns2="http://schemas/framework/baseresponse" xmlns:ns20="http://schemas/framework/fatalexception" xmlns:ns21="http://services/businessdomain/distributionmanagement/maintenance/businessdocumentmaintenance" xmlns:ns3="http://schemas/framework/contextsummary" xmlns:ns4="http://schemas/framework/param" xmlns:ns5="http://schemas/framework/servicestatus" xmlns:ns6="http://schemas/framework/messagetype" xmlns:ns7="http://schemas/framework/businessandservicestatus" xmlns:ns8="http://schemas/framework/businessstatus" xmlns:ns9="http://schemas/framework/serviceexception">
<AsOfDt>2011-01-01-04:00</AsOfDt>
<ApplicationInfo>
<ApplicationId>ABC</ApplicationId>
<ApplicationVersion>1.0</ApplicationVersion>
</ApplicationInfo>
<FolderInfo>
<FolderDetails>
<BusinessTypeCd xmlns="" xmlns:ns22="http://services/businessdomain/distributionmanagement/maintenance/maintenancerequestsresponses" code="J40"/>
</FolderDetails>
<FolderName>GY67898</FolderName>
<FolderTypeCd code="ABC"/>
</FolderInfo>
<MIMETypeCd code="pdf"/>
</ns21:InsertBusinessDocumentRequest>
</soap:Body>
</soap:Envelope>
あなたが見ることができるように、XMLの他の要素とは異なり、BusinessTypeCdの要素は、2個のxmlnsタグを持っている - 1つの空そして、名前空間と1:
:<BusinessTypeCd xmlns="" xmlns:ns22="http://services/businessdomain/distributionmanagement/maintenance/maintenancerequestsresponses" code="J40"/>
は、しかし、私は同じように、要素が他の要素のように生成させたいです
<BusinessTypeCd code="J40"/>
誰かがBusinessTypeCd要素からxmlnsタグを削除する方法を教えてもらえますか?どんな助けでも本当に感謝しています。
@Alochiあなたの解決策を試しました。 \t \t \t \t \t 動作しません –
tarares