如何删除命名空间(这里是请求xml中的ws)
public class SOAPInputGenerator2 {
public static void main(String[] args) throws Exception {
WsdlProject project = new WsdlProject();
String url = new String("http://ws.cdyne.com/emailverify/Emailvernotestemail.asmx?WSDL");
WsdlInterface[] wsdls = WsdlImporter.importWsdl(project, url);
WsdlInterface wsdl = wsdls[0];
Iterator<com.eviware.soapui.model.iface.Operation> itr = wsdl.getOperationList().iterator();
WsdlOperation op;
while (itr.hasNext()) {
op = (WsdlOperation) itr.next();
System.out.println("Operation: " + op.getName());
System.out.println("Request here: ");
System.out.println(op.createRequest(true));
System.out.println("Response here: ");
System.out.println(op.createResponse(true));
}
}
我上面的课程产生这样的请求:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" **xmlns:ws="http://ws.cdyne.com/">**
<soap:Header/>
<soap:Body>
**<ws:AdvancedVerifyEmail>**
<!--Optional:-->
**<ws:email>?</ws:email>**
**<ws:timeout>?</ws:timeout>**
<!--Optional:-->
**<ws:LicenseKey>?</ws:LicenseKey>
</ws:AdvancedVerifyEmail>**
</soap:Body>
</soap:Envelope>
但预期结果没有命名空间。我已经尝试了[Customising JAX-WS prefix of a SOAP response和[Removing namespace prefix in the output of Spring WS web service的解决方案,但未获得预期的输出
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ws="http://ws.cdyne.com/">
<soap:Header/>
<soap:Body>
<AdvancedVerifyEmail>
<!--Optional:-->
<email>?</email>
<timeout>?</timeout>
<!--Optional:-->
<LicenseKey>?</LicenseKey>
</AdvancedVerifyEmail>
</soap:Body>
</soap:Envelope>
答案 0 :(得分:0)
您无法删除原始响应XML的命名空间。尝试使用任何数据转换API(如Smooks或推土机)根据您的要求转换响应xml。