简体   繁体   English

调用SOAP Web服务的Java / Groovy方法(版本1.2)

[英]Java/Groovy method to Invoke SOAP Web Service (Version 1.2)

I am trying to invoke Web Service (Version 1.2 and dont have a Version 1.1 for this service) using Java/Groovy code. 我正在尝试使用Java / Groovy代码调用Web服务(1.2版,并且该服务没有1.1版)。 I have tried below options 我已经尝试了以下选项

Using SAAJ 使用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)

Using Groovy WsLite 使用Groovy WsLite

 def client = new SOAPClient(<<endpoint>>)
 def response = client.send(SOAPVersion.V1_2, <<RequestXML>>)

In both cases the I am receivig and error from service indicating version mismatch. 在这两种情况下,我都从服务中接收到错误并指示版本不匹配。 Underlying architecture is Oracle Service Bus. 基础架构是Oracle Service Bus。

I am able to invoke Web Services which are available with both Versions 1.1 and 1.2 with the same code. 我可以使用相同的代码调用版本1.1和1.2都可用的Web服务。 I am suspecting that in this case we are able to invoke only Service belonging to version 1.1 我怀疑在这种情况下,我们只能调用属于版本1.1的服务

Could someone help me understand what is that I am missing here? 有人可以帮助我了解我在这里想念的是什么吗?

The issue was resolved by adding SOAPAction as mimeheader in case of SOAP version 1.2. 通过在SOAP 1.2版中添加SOAPAction作为mimeheader来解决此问题。 I was able to resolve this issue by passing SOAPAction along with the SOAPVersion 通过将SOAPAction和SOAPVersion一起传递,我能够解决此问题

In case of SAAJ passed 如果SAAJ通过了

MimeHeaders mimeh = message.getMimeHeaders();
mimeh.addHeader("SOAPAction",<<soapaction>>);

In case of Groovy wslite 如果是Groovy wslite

def response = client.send(SOAPVersion.V1_2, SOAPAction: <<soapaction>>,<<RequestXML>>)

Your underlying oracle service bus might be configured to support only SOAP 1.1 version. 您的基础oracle服务总线可能配置为仅支持SOAP 1.1版本。 Did you change your code to use SOAPConstants.SOAP_1_1_PROTOCOL and try the same. 您是否更改了代码以使用SOAPConstants.SOAP_1_1_PROTOCOL并尝试相同的操作。

If this works, your OSB has to be enabled to support both 1.1 and 1.2 soap versions. 如果可行,则必须启用OSB以支持1.1和1.2肥皂版本。

Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM