Ive been working on a soap client since a time and I still cannot figure it out.
I have this error:
Exception in thread "main" java.lang.IllegalAccessError: tried to access field org.apache.cxf.staxutils.OverlayW3CDOMStreamWriter.isOverlaid from class org.apache.cxf.binding.soap.saaj.SAAJStreamWriter
at org.apache.cxf.binding.soap.saaj.SAAJStreamWriter.getPrefix(SAAJStreamWriter.java:79)
at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.writeSoapEnvelopeStart(SoapOutInterceptor.java:109)
at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleMessage(SoapOutInterceptor.java:87)
at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleMessage(SoapOutInterceptor.java:67)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:514)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:423)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:324)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:277)
at org.apache.cxf.endpoint.ClientImpl.invokeWrapped(ClientImpl.java:312)
at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:321)
at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:240)
at com.sigetel.web.web.rest.consumer.SoapClient.invoke(SoapClient.java:63)
at com.sigetel.web.web.rest.consumer.SoapClient.main(SoapClient.java:37)
Disconnected from the target VM, address: '127.0.0.1:60128', transport: 'socket'
Process finished with exit code 1
I saw its kinda common but still cannot make it work.
Here is my code:
Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE);
SOAPMessage response;
SOAPBody responseBody;
dispatch.getRequestContext().put(Dispatch.SOAPACTION_USE_PROPERTY, true);
dispatch.getRequestContext().put(Dispatch.SOAPACTION_URI_PROPERTY, soapActionUri);
try {
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();
SOAPPart soapPart = message.getSOAPPart();
StreamSource msgSrc = new StreamSource(new StringReader(request));
soapPart.setContent(msgSrc);
message.saveChanges();
response = dispatch.invoke(message);
responseBody = response.getSOAPBody();
....
Reelevant dependencies that might be related:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>3.1.6</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>org.apache.ws.security</groupId>
<artifactId>wss4j</artifactId>
<version>1.6.11</version>
</dependency>
and these ones:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-spring-boot-starter-jaxws</artifactId>
<version>3.1.11</version>
</dependency>
Any idea about this error?
As you may have already noticed, you have incompatible versions of SAAJStreamWriter and OverlayW3CDOMStreamWriter.
SAAJStreamWriter
is located in package cxf-rt-bindings-soap
, which is provided by:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-spring-boot-starter-jaxws</artifactId>
<version>3.1.11</version>
</dependency>
OverlayW3CDOMStreamWriter
is located in pachage cxf-core
, which is provided by:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>3.1.6</version>
</dependency>
Try one of the latest versions of org.apache.cxf - 3.1.13 or 3.2.0 - the same version for both dependencies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With