prolog中意外的EOF

时间:2011-06-28 14:22:03

标签: cxf

在客户端,我通过以下方式创建了3个附件:

public String sendMessage(MMSMessage mmsMessage, String formatCDR, FlowSessionData flowSessionData)
        throws IOException, ServiceException, PolicyException {

    SendMessage sendMessage = sendMessageService.getSendMessage();
    int index = 1;
    List<Attachment> atts = new ArrayList<Attachment>();
    BufferedImage image =  ImageIO.read(new URL(mmsMessage.getImgPath()));
    atts.add(createAttachmentPart(mmsMessage.getImgMimeType(), image, index));
    if (mmsMessage.getPrerollText() != null) {
        atts.add(createAttachmentPart("text/plain", mmsMessage.getPrerollText(), index++));
    }
    if (mmsMessage.getPostrollText() != null) {
        atts.add(createAttachmentPart("text/plain", mmsMessage.getPostrollText(), index++));
    }
    setServiceParams((BindingProvider) sendMessage, atts, configService.getSendMessageEndpointAddress());
    String value = null;
    validateURI(configService.getParlayxCallbackEndpointService() + "/" + NOTOFICATION_MMS_INTERFACE);
    SimpleReference correlator = new SimpleReference();
    correlator.setCorrelator(formatCDR);
    correlator.setInterfaceName(NOTOFICATION_MMS_INTERFACE);
    correlator.setEndpoint(configService.getParlayxCallbackEndpointService() + "/" + NOTOFICATION_MMS_INTERFACE);
    String toNumber = mmsMessage.getSmsServiceActivationNumber().get(0);
    if (!toNumber.startsWith(MSGConstants.PHONE_URI_PREFIX)) {
        if (!toNumber.startsWith("+")) {
            toNumber = "+" + toNumber;
        }
        toNumber = MSGConstants.PHONE_URI_PREFIX + toNumber;
    }
    validateURI(toNumber);
    List<String> addr = new ArrayList<String>();
    addr.add(toNumber);
    value = sendMessage.sendMessage(addr, mmsMessage.getSenderAddress(), mmsMessage.getSubject(), null, null,
            correlator);
    LOGGER.info(value);
    return value;
}

private Attachment createAttachmentPart(String mimeType, Object data, int index) {
        return new AttachmentImpl(String.valueOf(index), new DataHandler(data, mimeType));
    }

private void setServiceParams(BindingProvider serviceInf, Collection<Attachment> attachments, String endPoint) {
        Map<String, Object> requestContext = serviceInf.getRequestContext();
        requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endPoint);
        requestContext.put(BindingProvider.USERNAME_PROPERTY, configService.getParlayxEndPointUserName());
        requestContext.put(BindingProvider.PASSWORD_PROPERTY, configService.getParlayxEndPointPassword());
        final Client client = ClientProxy.getClient(serviceInf);
        final HTTPConduit http = (HTTPConduit) client.getConduit();
        final HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
        httpClientPolicy.setReceiveTimeout(configService.getParlayxEndPointTimeOut());
        httpClientPolicy.setAllowChunking(false);
        httpClientPolicy.setConnectionTimeout(configService.getParlayxEndPointTimeOut());
        http.setClient(httpClientPolicy);
        if (attachments != null && !attachments.isEmpty()) {
            requestContext.put(org.apache.cxf.message.Message.ATTACHMENTS, attachments);
        }
    }

我收到以下例外情况,原因是什么以及如何解决?

  

警告:拦截器   {http://www.csapi.org/wsdl/parlayx/multimedia_messaging/send/v2_4/service}SendMessageService#{http://www.csapi.org/wsdl/parlayx/multimedia_messaging/send/v2_4/interface}sendMessage   抛出异常,现在解除   org.apache.cxf.binding.soap.SoapFault:   读取XMLStreamReader时出错。在   org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:222)     在   org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:60)     在   org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:255)     在   org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:755)     在   org.apache.cxf.transport.http.HTTPConduit $ WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2335)     在   org.apache.cxf.transport.http.HTTPConduit $ WrappedOutputStream.handleResponse(HTTPConduit.java:2193)     在   org.apache.cxf.transport.http.HTTPConduit $ WrappedOutputStream.close(HTTPConduit.java:2037)     在   org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)     在   org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:697)     在   org.apache.cxf.interceptor.MessageSenderInterceptor $ MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)     在   org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:255)     在   org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:516)     在   org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:313)     在   org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:265)     在   org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)     在   org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124)     在$ Proxy92.sendMessage(未知   来源)at   com.amobee.common.sms.ParlayxMessagingService.sendMessage(ParlayxMessagingService.java:105)     在   com.amobee.nc.protocol.msg.MMSResponseBuilder.buildResponseMessage(MMSResponseBuilder.java:96)     在   com.amobee.nc.protocol.msg.BaseMSGResponseWriter.getResponse(BaseMSGResponseWriter.java:59)     在   com.amobee.nc.protocol.AbstractResponseWriter.write(AbstractResponseWriter.java:75)     在   com.amobee.frontend.servlets.AbstractBaseServlet.runCommand(AbstractBaseServlet.java:124)     在   com.amobee.frontend.servlets.AbstractBaseServlet.doGet(AbstractBaseServlet.java:64)     在   javax.servlet.http.HttpServlet.service(HttpServlet.java:575)     在   javax.servlet.http.HttpServlet.service(HttpServlet.java:668)     在   org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)     在   org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)     在   org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)     在   org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)     在   org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)     在   org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)     在   org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)     在   org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)     在   org.mortbay.jetty.Server.handle(Server.java:326)     在   org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)     在   org.mortbay.jetty.HttpConnection $ RequestHandler.headerComplete(HttpConnection.java:923)     在   org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)     在   org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)     在   org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)     在   org.mortbay.jetty.bio.SocketConnector $ Connection.run(SocketConnector.java:228)     在   org.mortbay.thread.QueuedThreadPool $ PoolThread.run(QueuedThreadPool.java:582)   引起:   com.ctc.wstx.exc.WstxEOFException:   意外的EOF在prolog的[row,col   {unknown-source}]:[1,0] at   com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:682)     在   com.ctc.wstx.sr.BasicStreamReader.handleEOF(BasicStreamReader.java:2090)     在   com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:1996)     在   com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1100)     在   com.ctc.wstx.sr.BasicStreamReader.nextTag(BasicStreamReader.java:1123)     在   org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:122)     ......还有40多个

谢谢Daniela

1 个答案:

答案 0 :(得分:0)

此异常意味着您在XML消息中具有文件结束字符,您应该使用Base64bit类型来使用Web服务中的附件来避免此类错误。