SOAP 웹 서비스를 사용해야하는 응용 프로그램을 작성 중입니다. CXF를 사용하여 웹 서비스의 WSDL에서 스텁을 만들었습니다. 요청의 요소CXF + Java : xmlns 속성을 제거하는 방법
하나는 다음과 같습니다
나는 전체 요청, 나는 이름이 "businessTypeCode가"를 가진 요소를 만들고에 추가하고를 만드는 오전 내 어댑터 클래스에서@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;
}
}
요소 목록.
<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 요소는 두 가지의 xmlns 태그가 - 빈 하나를 다음과 같이 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);
, 그것은 본다 와 네임 스페이스와 하나
:<BusinessTypeCd xmlns="" xmlns:ns22="http://services/businessdomain/distributionmanagement/maintenance/maintenancerequestsresponses" code="J40"/>
는하지만이 같은 요소가 다른 요소를 생성 할
<BusinessTypeCd code="J40"/>
누군가가 BusinessTypeCd 요소에서 xmlns 태그를 제거하는 방법을 알려줄 수 있습니까? 어떤 도움이라도 대단히 감사합니다.
@Alochi 귀하의 해결책을 시도했습니다. 다음과 같이 요소를 만듭니다. \t \t \t \t \t 작동하지 않습니다. –
tarares