tôi cố gắng gọi dịch vụ web SOAP HTTPS thông qua mã java:Cách thêm tiêu đề vào yêu cầu SOAP?
URL url = new URL("https://somehost:8181/services/"SomeService?wsdl");
QName qname = new QName("http://services.somehost.com/", "SomeService");
Service service = Service.create(url, qname);
SomeService port = service.getPort(SomeService .class);
port.doSomething();
Nhưng có được ngoại lệ:
threw an unexpected exception: javax.xml.ws.soap.SOAPFaultException: Security Requirements not met - No Security header in message
Khi tôi analized mẫu yêu cầu đúng tôi xác định nó phải chứa tiêu đề:
<S:Header>
<To xmlns="http://www.w3.org/2005/08/addressing">http://somehost:8181/services/SomeService</To>
<Action xmlns="http://www.w3.org/2005/08/addressing">https://somehost:8181/services/"SomeService/doSomethingRequest</Action>
<ReplyTo xmlns="http://www.w3.org/2005/08/addressing">
<Address>http://www.w3.org/2005/08/addressing/anonymous</Address>
</ReplyTo>
<MessageID xmlns="http://www.w3.org/2005/08/addressing">uuid:3428539e-d645-72ae-adc0-5423c1e68942</MessageID>
<wsse:Security S:mustUnderstand="true">
<wsu:Timestamp wsu:Id="_1" xmlns:ns14="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512" xmlns:ns13="http://schemas.xmlsoap.org/soap/envelope/">
<wsu:Created>2013-01-15T16:36:30Z</wsu:Created>
<wsu:Expires>2014-01-15T14:06:30Z</wsu:Expires>
</wsu:Timestamp>
</wsse:Security>
Vậy làm cách nào để thêm tiêu đề này vào yêu cầu SOAP của tôi?
Đây là chính xác những gì tôi đang tìm kiếm. Cảm ơn bạn cho ví dụ kỹ lưỡng của bạn. –
bạn được chào đón –
cảm ơn bạn rất nhiều. bạn đã cứu cả ngày sắp tới của tôi! –