2 fengvincent fengvincent 于 2017.01.09 18:47 提问

利用myeclipse自动生成web service client,测试调用接口时发生错误

下面是我的wsdl内容:

 <?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
    targetNamespace="http://112.15.179.187:82/service/yqyy.php"
    xmlns:tns="http://112.15.179.187:82/service/yqyy.php"
    xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding"
    xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">

    <wsdl:types>
        <xsd:schema  targetNamespace="http://112.15.179.187:82/service/yqyy.php">
            <xsd:element name="apply" >
              <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element minOccurs="1" maxOccurs="1"
                            name="in" type="xsd:string" />
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="applyResponse" >
               <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element minOccurs="0" maxOccurs="1"
                            name="out" type="xsd:string" />
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
        </xsd:schema>
    </wsdl:types>
    <wsdl:message name="applyResponse">
        <wsdl:part name="baseUrl" element="tns:applyResponse" />
    </wsdl:message>
    <wsdl:message name="applyRequest">
      <wsdl:part name="arr" element="tns:apply"></wsdl:part>
    </wsdl:message>
    <wsdl:portType name="yqyyPortType">
        <wsdl:operation name="apply">
            <wsdl:input name="applyRequest"
                message="tns:applyRequest" />
            <wsdl:output name="applyResponse"
                message="tns:applyResponse" />
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="yqyyHttpBinding"
        type="tns:yqyyPortType">
        <wsdlsoap:binding style="document"
            transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="apply">
            <wsdlsoap:operation soapAction="http://112.15.179.187:82/service/yqyy.php" />
            <wsdl:input name="applyRequest">
                <wsdlsoap:body use="literal" />
            </wsdl:input>
            <wsdl:output name="applyResponse">
                <wsdlsoap:body use="literal" />
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="yqyy">
        <wsdl:port name="yqyyHttpPort"
            binding="tns:yqyyHttpBinding">
            <wsdlsoap:address
                location="http://112.15.179.187:82/service/yqyy.php" />
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

测试调用是报的错误如下:

 Exception in thread "main" com.sun.xml.ws.protocol.soap.MessageCreationException: Couldn't create SOAP message due to exception: XML reader error: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
Message: Content is not allowed in prolog.
    at com.sun.xml.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:292)
    at com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:171)
    at com.sun.xml.xwss.XWSSClientPipe.process(XWSSClientPipe.java:118)
    at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:115)
    at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
    at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554)
    at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
    at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
    at com.sun.xml.ws.client.Stub.process(Stub.java:248)
    at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:135)
    at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:109)
    at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89)
    at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:118)
    at com.sun.proxy.$Proxy32.apply(Unknown Source)
    at test.Test.main(Test.java:18)
Caused by: com.sun.xml.ws.streaming.XMLStreamReaderException: XML reader error: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
Message: Content is not allowed in prolog.
    at com.sun.xml.ws.streaming.XMLStreamReaderUtil.wrapException(XMLStreamReaderUtil.java:267)
    at com.sun.xml.ws.streaming.XMLStreamReaderUtil.next(XMLStreamReaderUtil.java:95)
    at com.sun.xml.ws.streaming.XMLStreamReaderUtil.nextContent(XMLStreamReaderUtil.java:110)
    at com.sun.xml.ws.streaming.XMLStreamReaderUtil.nextElementContent(XMLStreamReaderUtil.java:100)
    at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:174)
    at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:296)
    at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:128)
    at com.sun.xml.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:287)
    ... 14 more
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
Message: Content is not allowed in prolog.
    at com.sun.xml.stream.XMLReaderImpl.next(XMLReaderImpl.java:563)
    at com.sun.xml.ws.util.xml.XMLStreamReaderFilter.next(XMLStreamReaderFilter.java:92)
    at com.sun.xml.ws.streaming.XMLStreamReaderUtil.next(XMLStreamReaderUtil.java:76)
    ... 20 more

网上翻遍我还是不知道怎么解决这个问题,紧急求助!!

1个回答

zhangpan_soft
zhangpan_soft   2017.01.09 19:03

应该是你的发送的内容不支持,你把要发送的东东都序列化,实现序列化接口,试试

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!