Я пытаюсь получить доступ к службе SOAP. Для этого я создаю запрос SOAP вручную (который я делаю). Проблема заключается в том, что, когда яHttpURLConnection параметр POST параметр URL
URL urli = new URL("http://www.myserver.com//x/y/z/a/b/c/d/myUrlWS.jws");
HttpURLConnection c = (HttpURLConnection) urli.openConnection();
c.setRequestMethod("POST");
c.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
c.setRequestProperty("Content-Length", bytes.length+"");
c.setRequestProperty("SOAPAction", "");
...
c.getInputStream();
Дело в том, что заголовок HTTP показывает этот путь:
POST /x/y/z/a/b/c/d/myUrlWS.jws
...(reset of http header)...
SOAP Message
Я получаю сообщение об ошибке с сервером, и я думаю, что POST в HTTP должны быть как:
POST/
или
POST /action
или
POST /myUrlWS.jws
Так что я не знаю, как изменить значение параметра POST в заголовке. Как мне это сделать без изменения URL/адреса подключения?
EDIT - SOAP-ответ от сервера
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header/><env:Body><env:Fault><faultcode>env:Server</faultcode><faultstring>[Server CodecHandler] Failed to decode
-> Unable to find xml element for parameter: documentos
</faultstring><detail><java:string xmlns:java="java.io">weblogic.wsee.codec.CodecException: Unable to find xml element for parameter: documentos
</java:string></detail></env:Fault></env:Body></env:Envelope>
ПОЛНЫЙ HTTP REQUEST
POST /x/y/z/a/b/c/d/myUrlWS.jws HTTP/1.1
Content-Type: text/xml; charset=utf-8
SOAPAction:
User-Agent: Java/1.7.0_75
Host: wwwW.somehost.some.gov.br
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
Content-Length: 2026
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:WL5G3N0="http://schemas.xmlsoap.org/wsdl/" xmlns:WL5G3N1="http://www.openuri.org/" xmlns:WL5G3N2="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:WL5G3N3="http://www.openuri.org/2006/12/wsdl/upgradedJWS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<WL5G3N1:enviarDados xmlns:WL5G3N1="http://www.openuri.org/">
<emitente>
<CNPJEmitente>11111111</CNPJEmitente>
<Email>[email protected]</Email>
</emitente>
<documentos>
<Documento>
<TipoPagamento>1</TipoPagamento>
<TipoDocumento>2</TipoDocumento>
<DataPagamento>13/04/15</DataPagamento>
<ItensPagamentos>
<ItemPagamento>
<TipoId>1</TipoId>
<Cnpj>1111111111</Cnpj>
<CodigoProduto>11111</CodigoProduto>
<DataFatoGerador>13/04/15</DataFatoGerador>
<DataVencimento>13/04/15</DataVencimento>
<DddContribuinte>16</DddContribuinte>
<EnderecoContribuinte>SOME NAME</EnderecoContribuinte>
<MunicipioContribuinte>NAME</MunicipioContribuinte>
<UFContribuinte>SP</UFContribuinte>
<CepContribuinte>11111111</CepContribuinte>
<TelefoneContribuinte>111111</TelefoneContribuinte>
<Natureza>1</Natureza>
<NomeRazaoSocial>SOME NAME</NomeRazaoSocial>
<NotaFiscalCnpj>1111111</NotaFiscalCnpj>
<NotaFiscalDataEmissao>2014-12-04</NotaFiscalDataEmissao>
<NotaFiscalNumero>111111</NotaFiscalNumero>
<NotaFiscalSerie>1</NotaFiscalSerie>
<NotaFiscalTipo>NF-e</NotaFiscalTipo>
<NumControleContribuinte>111111</NumControleContribuinte>
<TipoApuracao>2</TipoApuracao>
<PeriodoReferenciaAno>2015</PeriodoReferenciaAno>
<PeriodoReferenciaMes>04</PeriodoReferenciaMes>
<PeriodoReferenciaDecendio>2</PeriodoReferenciaDecendio>
<DiaVencimento>13/04/15</DiaVencimento>
<ValorICMSPrincipal>221.21</ValorICMSPrincipal>
<ValorTotal>221.21</ValorTotal>
</ItemPagamento>
</ItensPagamentos>
</Documento>
</documentos>
</WL5G3N1:enviarDados>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
WSDL здесь: WSDL
Есть ли трассировка стека? или какая именно ошибка? –
Я не могу получить доступ к серверу, но я получаю HTTP 500 с ответом SOAP, добавленным выше – fredcrs