Я могу успешно вызвать службу SOAP с помощью Curl, но тот же запрос, отправленный через Apache CXF, не удается.JAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Я могу успешно вызвать службу SOAP с помощью Curl, но тот же запрос, отправленный через Apache CXF, не удается.

Сообщение Anonymous »

Рабочий запрос на завивку:
curl -v -X POST \

-H "Content-Type: text/xml;charset=UTF-8" \

-H "Авторизация: Test " \

-H "SOAPAction: urn: CreateEmployeeByCode" \

--data '...' \

http://example.com/service
Вывод запроса CXF (не работает)
Http-Метод: POST

Content-Type: text/xml

Заголовки: {Accept=[/], Authorization=[TEST ], SOAPAction=[urn:CreateEmployeeByCode]}

Полезная нагрузка: ...
@Component
публичный класс SoapHeaderInterceptor расширяет AbstractPhaseInterceptor {

Код: Выделить всё

public SoapHeaderInterceptor() {
super(Phase.PRE_PROTOCOL);
}

@Override
public void handleMessage(Message message) {

Map headers =
(Map) message.get(Message.PROTOCOL_HEADERS);

if (headers == null) {
headers = new HashMap();
message.put(Message.PROTOCOL_HEADERS, headers);
}

// Authorization (must match curl exactly)
headers.put("Authorization",
Collections.singletonList("Test "));

// SOAPAction (note the space after urn:)
headers.put("SOAPAction",
Collections.singletonList("urn: CreateEmployeeByCode"));

// Content-Type with charset
headers.put("Content-Type",
Collections.singletonList("text/xml;charset=UTF-8"));
}
}
@Configuration
публичный класс EmployeeSoapConfig {

Код: Выделить всё

@Value("${employee.soap.endpoint}")
private String endpointUrl;

@Bean
public EmployeeWebServicePortType employeePort(SoapHeaderInterceptor interceptor) {

EmployeeWebService service = new EmployeeWebService();
EmployeeWebServicePortType port = service.getEmployeeWebServicePort();

Client client = ClientProxy.getClient(port);
client.getEndpoint().getEndpointInfo().setAddress(endpointUrl);

// attach interceptor
client.getOutInterceptors().add(interceptor);

return port;
}
}

Подробнее здесь: https://stackoverflow.com/questions/798 ... t-sent-via
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»