how to pass String including comma in CXF service method

落爺英雄遲暮 提交于 2020-01-17 13:58:06

问题


I'm using camel cxf component to call web service. I'm trying to pass XML String, which has a comma (,). when I'm trying to pass XML string it throws below error.

Get the wrong parameter size to invoke the out s ervice, Expect size 1, Parameter size 2. Please check if the message body matches the CXFEndpoint POJO Dataformat request.

Here is my web service method

public String sendSMSRequest(
    @WebParam(name = "clientRequestXML", targetNamespace = "http://www.openuri.org/")
    String clientRequestXML);

I'm passing below XML String as clientRequestXML.

<BODY>
        <SCODE/>
        <SMSSERVICE>
            <SENDSMS_REQ>
                <TO>
                    <CIFNUMBER>73</CIFNUMBER>
                    <MOBILE>null</MOBILE>
                    <LANG>2</LANG>
                    <MESSAGE>Dear SCUST2, your id is 1112</MESSAGE>
                </TO>
            </SENDSMS_REQ>
        </SMSSERVICE>
    </BODY>

please help me to solve this problem. I want to send String with comma (,)


回答1:


CxfProducer (in the POJO data format) expects a List. It parses the String and the comma gets interpreted as a list separator. You should pass the List as a request. For example:

Arrays.asList(clientRequestXML);


来源:https://stackoverflow.com/questions/25420522/how-to-pass-string-including-comma-in-cxf-service-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!