【问题标题】:Removing namespace prefix from Web Service Request从 Web 服务请求中删除命名空间前缀
【发布时间】:2016-03-01 10:57:10
【问题描述】:

如何删除命名空间(在请求 xml 中)

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>

【问题讨论】:

    标签: java web-services xsd wsdl


    【解决方案1】:

    您不能删除原始响应 XML 的命名空间。尝试使用任何数据转换 API(如 Smooks 或 dozer)根据您的要求转换响应 xml。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多