通过发送带命名空间的参数来调用soap webservice

时间:2015-06-27 11:28:18

标签: java web-services soap

我想通过Java调用soap webservice方法。但我无法使用命名空间生成xml includes参数。 喜欢: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <sendMsg xmlns="http://tempuri.org/"> <as_xml xmlns="http://tempuri.org/">msg</as_xml> </sendMsg> </soapenv:Body> </soapenv:Envelope>

我能产生的是: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <sendMsg xmlns="http://tempuri.org/"> <as_xml>msg</as_xml> </sendMsg> </soapenv:Body> </soapenv:Envelope>

请告诉我该怎么办? 这是我的代码:

    Service service = new Service();
    try {
        String namespace="http://tempuri.org/";

        Call call = (Call)service.createCall();

        call.setOperationName(new QName(namespace, methodName));
        call.setTargetEndpointAddress(new URL("http://192.168.1.1/webservice_app/webservice.asmx"));

        call.setUseSOAPAction(true);
        call.setSOAPActionURI(namespace + "sendMsg");
        call.setEncodingStyle(null);
        call.setProperty("sendXsiTypes", Boolean.FALSE);
        call.setProperty("sendMultiRefs", Boolean.FALSE);

        call.addParameter(new QName(namespace, "as_xml"), XMLType.XSD_STRING, ParameterMode.IN);

        call.setReturnType(XMLType.XSD_STRING);

        String xmlResult = (String)call.invoke(new Object[]{"msg"});

        return xmlResult;
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (RemoteException e) {
        e.printStackTrace();
    }

我错过了什么配置吗? 请帮忙。

0 个答案:

没有答案
相关问题