• web service:AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException


    在调用webservice时,出现如下错误信息:
    AxisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
    faultActor:
    faultNode:
    faultDetail:
    {http://xml.apache.org/axis/}hostname:Websevice2.site

    org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
    at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
    at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
    at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
    at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
    at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
    at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
    at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at com.prochanges.services.register.RegisterService.setCallBackAddr1(RegisterService.java:31)
    at com.prochanges.services.register.RegisterService.main(RegisterService.java:72)

    实现代码:

        public String setCallBackAddr() {
            try {
                String url = "http://192.168.0.27:7777/axis2/services/SMSService?wsdl";
                String uc = "18926380454";
                String oldpw = "Yj123456";
                String rand = getRandom1();
                String pw = MD5Encode(rand.concat(oldpw).concat(oldpw));
                Service service = new Service();
                Call call = (Call) service.createCall();
                call.setTargetEndpointAddress(new java.net.URL(endpoint));
                call.setOperationName("setCallBackAddr"); // 调用的方法名
                call.setReturnType(XMLType.XSD_STRING); // 返回值类型
                call.addParameter("uc", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
                call.addParameter("pw", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
                call.addParameter("rand",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
                call.addParameter("url", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
                Object[] o = {uc, pw, rand, url};
                String connID = (String)call.invoke(o);
                System.out.println("connID: " + connID);
                return connID;
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

    问题原因:

      注意参数部分,e.g. 

    错误方式:
    call.addParameter(uc, org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
    正确方式:需要对参数uc加上双引号
    call.addParameter("uc", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
    WSDL文件描述:
    <wsdl:message name="setCallBackAddrRequest">
    <wsdl:part name="uc" type="xsd:string"></wsdl:part>
    <wsdl:part name="pw" type="xsd:string"></wsdl:part>
    <wsdl:part name="rand" type="xsd:string"></wsdl:part>
    <wsdl:part name="url" type="xsd:string"></wsdl:part>
    </wsdl:message>
  • 相关阅读:
    Go开发中的一些注意事项
    ubuntu 下的一个很好的Github 客户端
    ubuntu安装 dotnet core sdk ,runtime
    ubuntu 彻底卸载自带的firefox 其他软件应该也是一致。
    企业应用架构研究系列二十六:信号量SemaphoreSlim与Semaphore
    9th sduwhcpc
    CS224N Lecture 2
    CSP认证
    CS224N Lecture 1
    【Substrate Collectables教程】【第2章Kitties】2 创建一个 Event
  • 原文地址:https://www.cnblogs.com/hutton/p/3782345.html
Copyright © 2020-2023  润新知