[英]How to Consume SOAP 1.2 Web Service Created in WCF by a Java Client?
[英]Java/Groovy method to Invoke SOAP Web Service (Version 1.2)
我正在嘗試使用Java / Groovy代碼調用Web服務(1.2版,並且該服務沒有1.1版)。 我已經嘗試了以下選項
使用SAAJ
String endpointURL = <<endpoint>>
SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
SOAPConnection soapConnection = soapConnectionFactory.createConnection();
// Send SOAP Message to SOAP Server
def Request = <<Request XML>>
InputStream is = new ByteArrayInputStream(Request.getBytes());
SOAPMessage soapMessage = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL).createMessage(null, is);
SOAPMessage soapResponse = soapConnection.call(soapMessage, endpointURL)
使用Groovy WsLite
def client = new SOAPClient(<<endpoint>>)
def response = client.send(SOAPVersion.V1_2, <<RequestXML>>)
在這兩種情況下,我都從服務中接收到錯誤並指示版本不匹配。 基礎架構是Oracle Service Bus。
我可以使用相同的代碼調用版本1.1和1.2都可用的Web服務。 我懷疑在這種情況下,我們只能調用屬於版本1.1的服務
有人可以幫助我了解我在這里想念的是什么嗎?
通過在SOAP 1.2版中添加SOAPAction作為mimeheader來解決此問題。 通過將SOAPAction和SOAPVersion一起傳遞,我能夠解決此問題
如果SAAJ通過了
MimeHeaders mimeh = message.getMimeHeaders();
mimeh.addHeader("SOAPAction",<<soapaction>>);
如果是Groovy wslite
def response = client.send(SOAPVersion.V1_2, SOAPAction: <<soapaction>>,<<RequestXML>>)
您的基礎oracle服務總線可能配置為僅支持SOAP 1.1版本。 您是否更改了代碼以使用SOAPConstants.SOAP_1_1_PROTOCOL並嘗試相同的操作。
如果可行,則必須啟用OSB以支持1.1和1.2肥皂版本。
謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.