带有附件的Message SoapUI

时间:2019-01-17 17:29:38

标签: javascript java soap soapui

下午好,我在发送带有附件的肥皂请求时遇到了问题。

每次将请求发送到端点时,都会收到错误消息

<? xml version = "1.0" encoding = "UTF-8"?>
<soapenv: Envelope xmlns: soapenv = "http://schemas.xmlsoap.org/soap/envelope/"> <soapenv: Body> <soapenv: Fault> <faultcode> soapenv: Server </ faultcode> <faultstring> OSB- 382000: Could not create SOAP message due to exception: org.jvnet.mimepull.MIMEParsingException: Missing start boundary </ faultstring> <detail> <with: stack-trace xmlns: con = "http://www.bea.com /wli/sb/context"> com.bea.wli.sb.service.handlerchain.HandlerException: Could not create SOAP message due to exception: org.jvnet.mimepull.MIMEParsingException: Missing start boundary>

我不知道我的问题实际上是在边界中还是在标题中。 有人可以在这件事上帮助我吗?

这里是用于发送带有文件的消息的类:

public String enviarRequestAttachments(String soapRequest, String clinicalInformationValue) {
    if (!checkParameters()) {
        return null;
    }

    try {

        byte[] encoded2 = soapRequest.getBytes("UTF-8");
        ByteArrayInputStream stream = new ByteArrayInputStream(encoded2);
        StreamSource source = new StreamSource(stream);

        SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
        SOAPConnection connection2 = soapConnectionFactory.createConnection();
        MessageFactory factory = MessageFactory.newInstance();

        SOAPMessage message = factory.createMessage(null, stream);
        message.getMimeHeaders().setHeader("Content-Type", "application/xop+xml");
        message.saveChanges();

        AttachmentPart attachment = message.createAttachmentPart(clinicalInformationValue, "application/xop+xml");
        attachment.setContentId("clinicalInformationValue.xml");
        message.addAttachmentPart(attachment);

        SOAPMessage response2 = connection2.call(message, endpoint);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        message.writeTo(out);
        String strMsg = new String(out.toByteArray());

        URL url = new URL(endpoint);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setDoOutput(true);
        connection.setDoInput(true);
        connection.setRequestProperty("Content-Type", "multipart/related; type=\"application/xop+xml\"; start=\"<rootpart@soapui.org>\"; start-info=\"text/xml\"; boundary=\"----=_Part_120_1983961350.1547743974197\"");
        int requestLength = strMsg.length();
        connection.setRequestProperty("Content-Length", Integer.toString(requestLength));
        connection.setRequestProperty("SOAPAction", action);
        connection.connect();

        OutputStreamWriter soapWriter;
        if (encodingOutput == null) {
            soapWriter = new OutputStreamWriter(connection.getOutputStream());
        } else {
            soapWriter = new OutputStreamWriter(connection.getOutputStream(), Charset.forName(encodingOutput));
        }
        soapWriter.write(strMsg, 0, requestLength);
        soapWriter.flush();

        BufferedReader soapReader;

        if (connection.getResponseCode() == 200) {
            soapReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
        } else {
            soapReader = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
        }

        StringBuilder sb = new StringBuilder();
        int ch = soapReader.read();
        while (ch != -1) {
            sb.append((char) ch);
            ch = soapReader.read();
        }

        String response = sb.toString();
        soapReader.close();
        connection.disconnect();
        return response;
    } catch (Exception e) {
        e.printStackTrace();
        return getRetornoXmlSoapAbrasf(false, e.getMessage());
    }
}

Here is also the upload image successfully made in the soapUI application

Abaixo segue tambem或xml com或envelopamento:

<soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:v1="http://ptu-clinico.unimed.com.br/schemas/servico/envio/informacao/res/v1.00"
    xmlns:v11="http://ptu.unimed.com.br/schemas/comum/tipos/complexos/transacional/v1.00"
    xmlns:v12="http://ptu.unimed.com.br/schemas/comum/tipos/complexos/institucional/v1.00"
    xmlns:v13="http://ptu-clinico.unimed.com.br/schemas/comum/tipos/complexos/demografico/v1.00"
    xmlns:v14="http://ptu.unimed.com.br/schemas/comum/tipos/complexos/demografico/v1.00"
    xmlns:v15="http://ptu-clinico.unimed.com.br/schemas/comum/tipos/complexos/profissional/v1.00"
    xmlns:v16="http://ptu.unimed.com.br/schemas/comum/tipos/complexos/profissional/v1.00"
    xmlns:v17="http://ptu-clinico.unimed.com.br/schemas/comum/tipos/complexos/anexos/v1.00"
    xmlns:xm="http://www.w3.org/2005/05/xmlmime">
    <soapenv:Header>
        <wsse:Security soapenv:mustUnderstand="1"
            xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
            xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <wsse:UsernameToken>
                <wsse:Username>tasy</wsse:Username>
                <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">SPf9ljV2UkhbhdNWGM5nlYPxyuE=</wsse:Password>
                <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">9GblyycsSpmzYxgaeMhSLA==</wsse:Nonce>
                <wsu:Created>2019-01-17T17:20:53.205Z</wsu:Created>
            </wsse:UsernameToken>
        </wsse:Security>
    </soapenv:Header>
    <soapenv:Body>
        <v1:requisicaoEnvioInformacaoRES>
            <!-- ##CabecalhoTransacao -->
            <v1:cabecalhoRequisicao>
                <!-- ##TransacaoVersionada -->
                <v11:transacao>
                    <v11:codigo>00720</v11:codigo>
                    <v11:versao>1.00</v11:versao>
                </v11:transacao>
                <!-- ##InformacaoRequisitante -->
                <v11:origem>
                    <!-- ##Entidade -->
                    <v11:entidade>
                        <!-- ##CodigoEntidade -->
                        <v12:codigo>
                            <v12:tipo>PRESTADOR</v12:tipo>
                            <v12:codigo>9999</v12:codigo>
                        </v12:codigo>
                        <!-- ##IdentificacaoEntidade -->
                        <v12:identificacao>
                            <!--Optional cadastroNacionalEstabelecimentosSaude:-->
                            <v12:cadastroNacionalEstabelecimentosSaude>6963447</v12:cadastroNacionalEstabelecimentosSaude>
                            <v12:descricao>Philips Clinical Informatics</v12:descricao>
                            <!-- ##IdentificacaoTributaria -->
                            <v12:identificacaoTributaria>
                                <!--You have a CHOICE of the next 2 items at this level-->
                                <v12:cadastroNacionalPessoaJuridica>01950338000177</v12:cadastroNacionalPessoaJuridica>
                            </v12:identificacaoTributaria>
                        </v12:identificacao>
                    </v11:entidade>
                    <!-- ##SistemaInformacao -->
                    <v11:sistema>
                        <v11:designacao>Tasy Philips</v11:designacao>
                        <v11:fornecedor>Philips Healthcare</v11:fornecedor>
                        <!--Optional versao:-->
                        <v11:versao>3.02.1740</v11:versao>
                    </v11:sistema>
                </v11:origem>
                <!-- ##InformacaoExecutante -->
                <v11:identificador>88cc93e8-4153-4fdd-a4a3-45a83509cddc</v11:identificador>
                <v11:data>2019-01-17T15:20:51</v11:data>
            </v1:cabecalhoRequisicao>
            <!-- ##CorpoRequisicaoCriacaoRES -->
            <v1:corpoRequisicao>
                <!-- ##Beneficiario -->
                <v1:beneficiario>
                    <!-- ##Identificacao -->
                    <v13:identificacao>
                        <v14:nome>Chester the Cheese Chester O Queijo</v14:nome>
                        <v14:dataNascimento>2002-09-27</v14:dataNascimento>
                        <v14:nomeMae>Mother Cheese</v14:nomeMae>
                        <v14:genero>
                            <v12:terminologia>gender#1.00</v12:terminologia>
                            <v12:codigo>MAL</v12:codigo>
                        </v14:genero>
                        <v14:estadoCivil>
                            <v12:terminologia>marital-status#2.00</v12:terminologia>
                            <v12:codigo>SIN</v12:codigo>
                        </v14:estadoCivil>
                        <v14:localNascimento>
                            <v12:terminologia>municipios-2014#2.00</v12:terminologia>
                            <v12:codigo>4202400</v12:codigo>
                        </v14:localNascimento>
                        <v14:nacionalidade>
                            <v12:terminologia>country#2.00</v12:terminologia>
                            <v12:codigo>BRA</v12:codigo>
                        </v14:nacionalidade>
                        <v14:carteirasUnimed>
                            <!--1 or more repetitions:-->
                            <v14:carteiraUnimed>
                                <v14:unimed>2231</v14:unimed>
                                <v14:numero>2314967912800</v14:numero>
                            </v14:carteiraUnimed>
                        </v14:carteirasUnimed>
                        <v14:identificacaoCivil>
                            <!--Optional:-->
                            <v14:cadastroPessoaFisica>06116319971</v14:cadastroPessoaFisica>
                            <v14:cartaoNacionalSaude>224093781570002</v14:cartaoNacionalSaude>
                            <!--Optional:-->
                            <!--Optional:-->
                            <v14:documentosIdentificacao>
                                <!--1 or more repetitions:-->
                                <v14:documentoIdentificacao>
                                    <v12:numero>55002151502</v12:numero>
                                    <v12:orgaoEmissor>SC</v12:orgaoEmissor>
                                    <v12:paisEmissor>
                                        <v12:terminologia>country#2.00</v12:terminologia>
                                        <v12:codigo>BRA</v12:codigo>
                                    </v12:paisEmissor>
                                </v14:documentoIdentificacao>
                            </v14:documentosIdentificacao>
                        </v14:identificacaoCivil>
                    </v13:identificacao>
                    <!--Optional:-->
                    <!-- ##Demografia -->
                    <!-- ##Contatos -->
                </v1:beneficiario>
                <!-- ##ProfissionalRequisitante -->
                <v1:profissional>
                    <!--You have a CHOICE of the next 2 items at this level-->
                    <v15:naoSaude>
                        <!-- ##Profissional -->
                        <v16:abreviatura>baferreira</v16:abreviatura>
                        <!--Optional:-->
                        <v16:nomeCompleto>Bruce Assis Ferreira</v16:nomeCompleto>
                        <v16:cadastroPessoaFisica>05713853977</v16:cadastroPessoaFisica>
                    </v15:naoSaude>
                </v1:profissional>
                <!-- ##ClinicalInformation -->
                <v1:informacaoClinica>
                    <v17:anexoComposicao xm:contentType="application/xml" xm:expectedContentTypes="application/xml">cid:bruce.xml</v17:anexoComposicao>
                </v1:informacaoClinica>
            </v1:corpoRequisicao>
        </v1:requisicaoEnvioInformacaoRES>
    </soapenv:Body>
</soapenv:Envelope>

0 个答案:

没有答案