call a SOAP web service that doesn't exist - java

I have deployed a WAR file with SOAP endpoints and created a handler to detect any call for all web services that the client may call. I want to detect the nonexistent web service but unfortunately, I am getting errors on Payara only if I deployed the WAR file on any other application server (glassfish or Tomcat) it works as expected the error has been logged by the handler. Here is an example for request/response using SOAPUi and web services deploy on Payara.
Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.jaxws.demo.jcg/">
soapenv:Header/
soapenv:Body
ser:getBooks
1
</ser:getBooks>
</soapenv:Body>
</soapenv:Envelope>
Response:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">
S:Server
java.lang.NullPointerException
</S:Fault>
</S:Body>
</S:Envelope>
I am getting this error on server.log
[2023-01-15T16:49:30.029+0300] [Payara 5.2021.7] [SEVERE] [AS-WSSECURITY-00001] [javax.enterprise.webservices.security] [tid: _ThreadID=740 _ThreadName=http-thread-pool::http-listener-2(620)] [timeMillis: 1673790570029] [levelValue: 1000] [[
Request processing failed.
java.lang.NullPointerException
at java.util.ArrayDeque.addLast(ArrayDeque.java:249)
at org.glassfish.api.invocation.InvocationManagerImpl.pushWebServiceMethod(InvocationManagerImpl.java:386)
at org.glassfish.webservices.MonitoringPipe.pushWebServiceMethod(MonitoringPipe.java:211)
at org.glassfish.webservices.MonitoringPipe.process(MonitoringPipe.java:132)
at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:89)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1106)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1020)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:989)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:847)
at com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(AbstractTubeImpl.java:106)
at com.sun.enterprise.security.webservices.CommonServerSecurityPipe.processRequest(CommonServerSecurityPipe.java:195)
at com.sun.enterprise.security.webservices.CommonServerSecurityPipe.process(CommonServerSecurityPipe.java:134)
at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:89)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1106)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1020)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:989)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:847)
at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:389)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:838)
The request/response for the same web service deployed on glassfish
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.jaxws.demo.jcg/">
soapenv:Header/
soapenv:Body
ser:getBooks
1
</ser:getBooks>
</soapenv:Body>
</soapenv:Envelope>
Response:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">SOAP-ENV:Header/<S:Body><S:Fault xmlns:ns3="http://www.w3.org/2003/05/soap-envelope">S:Client
Cannot find dispatch method for {http://service.jaxws/}getfBook
</S:Fault>
</S:Body>
</S:Envelope>

Related

Axis 2 Error :- org.apache.axis2.AxisFault: javax.xml.stream.XMLStreamException: Premature end of file encountered

I have gone through this posted question earlier, however my issue is different:
org.apache.axis2.AxisFault: javax.xml.stream.XMLStreamException:
Premature end of file encountered at
org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
org.apache.axis2.AxisFault: javax.xml.stream.XMLStreamException:
Premature end of file encountered at
org.apache.axis2.AxisFault.makeFault(AxisFault.java:430) at
org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:122)
at
org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:66)
at
org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:347)
at
org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:414)
at
org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225)
at
org.apache.axis2.client.OperationClient.execute(OperationClient.java:150)
Can anybody help me out please what I'm missing as this is working perfectly fine in my local machine. But failing onto my server environment.
Please let me know if more details are required.
I had added this jars in my server Web-Inf :
Please have a look at this SOAP request that we are hitting :
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:tem="http://tempuri.org/">
<soap:Header>
<tem:UserAuth>
<!--Optional:-->
<tem:UserName>?</tem:UserName>
<!--Optional:-->
<tem:Password>?</tem:Password>
</tem:UserAuth>
</soap:Header>
<soap:Body>
<tem:Cities/>
</soap:Body>
</soap:Envelope>

Hermes2 - "Cannot reconstruct the message from repository" error

My intention is to send ebxml message to MSH (Hermes2 http://www.cecid.hku.hk/hermes.php) through another Hermes2.
I am sending fairly simple message (with no attachments), this is the message:
POST /corvus/httpd/ebms/sender HTTP/1.0
User-Agent: PEAR-SOAP 0.12.0-beta
Host: 10.0.4.9
Content-Type: text/xml; charset=UTF-8
Content-Length: 698
SOAPAction: "PaymentAddRequest"
Connection: close
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<cpaId>ZSK_KOLEK</cpaId>
<service>http://www.squiz.pl/zsk/ebxml</service>
<action>PaymentAddRequest</action>
<convId>convId</convId>
<fromPartyId>KOLEK</fromPartyId>
<fromPartyType>urn:oasis:names:tc:ebxml-cppa:partyid-type:duns</fromPartyType>
<toPartyId>ZSK-C</toPartyId>
<toPartyType>urn:oasis:names:tc:ebxml-cppa:partyid-type:duns</toPartyType>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
In response I get following:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<message_id xmlns="http://service.ebms.edi.cecid.hku.hk/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" type="xsd:string">20150112-092001-65410#127.0.1.1</message_id>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Message gets registered, but then in logs/ebms.log I get following error
[Thread-1855 ] <ERROR> <cecid.ebms.spa> <Error in outbox task>
hk.hku.cecid.ebms.spa.task.MessageValidationException: Cannot reconstruct the message 20150112-092435-20713#127.0.1.1 from repository
by java.lang.RuntimeException: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to create envelope from given source:
by com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to create envelope from given source:
by javax.xml.transform.TransformerException: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
Also looking at repository table in DB I can see that a row has been inserted, content column contains message in hex form (\x3c3f786d6c2076657273696f6e3d...), once converted to ASCII it says:
<?xml version="1.0" encoding="UTF-8" ?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.xmlsoap.org/soap/envelope/ http://www.oasis-open.org/committees/ebxml-msg/schema/envelope.xsd">
<SOAP-ENV:Header xsi:schemaLocation="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd">
<eb:MessageHeader SOAP-ENV:mustUnderstand="1" eb:version="2.0" xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd">
<eb:From>
<eb:PartyId eb:type="urn:oasis:names:tc:ebxml-cppa:partyid-type:duns">KOLEK</eb:PartyId>
</eb:From>
<eb:To>
<eb:PartyId eb:type="urn:oasis:names:tc:ebxml-cppa:partyid-type:duns">ZSK-C</eb:PartyId>
</eb:To>
<eb:CPAId>ZSK_KOLEK</eb:CPAId>
<eb:ConversationId>convId</eb:ConversationId>
<eb:Service>http://www.squiz.pl/zsk/ebxml</eb:Service>
<eb:Action>PaymentAddRequest</eb:Action>
<eb:MessageData>
<eb:MessageId>20150112-092435-20713#127.0.1.1</eb:MessageId>
<eb:Timestamp>2015-01-12T09:24:35.207+01:00</eb:Timestamp>
</eb:MessageData>
<eb:DuplicateElimination/>
</eb:MessageHeader>
<eb:SyncReply SOAP-ENV:actor="http://schemas.xmlsoap.org/soap/actor/next" SOAP-ENV:mustUnderstand="1" eb:version="2.0" xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd"/>
<eb:AckRequested SOAP-ENV:actor="urn:oasis:names:tc:ebxml-msg:actor:toPartyMSH" SOAP-ENV:mustUnderstand="1" eb:signed="false" eb:version="2.0" xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd"/>
</SOAP-ENV:Header>
<SOAP-ENV:Body xsi:schemaLocation="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd"/>
</SOAP-ENV:Envelope>
but it doesn't get delivered to the endpoint, seems like Hermes2 doesn't even try to send it to the second Hermes2. Both instances have proper partnership configured.
Can someone point me in the right direction?
Ok, it took me a longer while to find the issue and then a solution, so hopefully I can save someones time.
Documentation on Hermes 2 installation says that it requires PostgreSQL 8.0 or later. This is a lie! Removing Postgres 9.3 and reinstalling Hermes with Postgres 8.4 solved the problem.

Mule - MuleMessage.getPayloadString() gives me java.io.IOException: Bad chunk size

I use Mule 3.5.0
I have a mule configuration where I accept HTTP requests, I add a SOAP header to them and I forward them to an external service and the result of that service call is returned:
Since I want to see what happens I write the generated request and response messages to folders. (Requests and Responses components).
For testing purposes I created a test method using the MuleClient functionality:
#Test
public void testOnlineServiceFlow() throws Exception
{
MuleClient client = new MuleClient(muleContext);
MuleMessage result = client.send("http://localhost:1234/in", "<acc:AccountDetailsRequest xmlns:acc=\"http://com/blog/samples/webservices/accountservice\"><acc:accountNumber>12345</acc:accountNumber></acc:AccountDetailsRequest>", null);
System.out.println(result.getPayloadAsString());
}
Everything works fine and after executing my test my response message is written to the folder location by the Responses component:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns3:AccountDetailsResponse xmlns:ns2="http://webservices.samples.blog.com" xmlns:ns3="http://com/blog/samples/webservices/accountservice">
<ns3:AccountDetails>
<ns2:AccountNumber>12345</ns2:AccountNumber>
<ns2:AccountName>Joe Bloggs</ns2:AccountName>
<ns2:AccountBalance>3400.0</ns2:AccountBalance>
<ns2:AccountStatus>Active</ns2:AccountStatus>
</ns3:AccountDetails>
</ns3:AccountDetailsResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
But then when my message returns in my client and I want to print it, I got following exception:
org.mule.api.transformer.TransformerException: Could not read InputStream.
at org.mule.transformer.simple.ObjectToString.createStringFromInputStream(ObjectToString.java:83)
at org.mule.transformer.simple.ObjectToString.doTransform(ObjectToString.java:54)
at org.mule.transformer.AbstractTransformer.transform(AbstractTransformer.java:419)
at org.mule.DefaultMuleMessage.getPayload(DefaultMuleMessage.java:375)
at org.mule.DefaultMuleMessage.getPayloadAsString(DefaultMuleMessage.java:630)
at org.mule.DefaultMuleMessage.getPayloadAsString(DefaultMuleMessage.java:565)
at be.healthconnect.handicare.OnlineServiceTest.testOnlineServiceFlow(OnlineServiceTest.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:46)
at org.junit.internal.runners.statements.FailOnTimeout$1.run(FailOnTimeout.java:28)
Caused by: java.io.IOException: Bad chunk size: HTTP/1.1 500 Internal Server Error
at org.apache.commons.httpclient.ChunkedInputStream.getChunkSizeFromInputStream(ChunkedInputStream.java:306)
at org.apache.commons.httpclient.ChunkedInputStream.nextChunk(ChunkedInputStream.java:221)
at org.apache.commons.httpclient.ChunkedInputStream.read(ChunkedInputStream.java:176)
at java.io.FilterInputStream.read(Unknown Source)
at org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:108)
at java.io.FilterInputStream.read(Unknown Source)
at org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:127)
at org.mule.model.streaming.DelegatingInputStream.read(DelegatingInputStream.java:54)
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1792)
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1769)
at org.apache.commons.io.IOUtils.copy(IOUtils.java:1744)
at org.mule.transformer.simple.ObjectToString.createStringFromInputStream(ObjectToString.java:78)
... 18 more
I don't know what the reason of this failure and how I could resolve it. Probably something is wrong in my flow configuration?
<flow name="Online_Service" doc:name="Online_Service">
<http:inbound-endpoint exchange-pattern="request-response" name="clientEndpoint" address="http://localhost:1234/in" doc:name="HTTP" contentType="text/xml"/>
<component doc:name="SOAP Header Creator">
<spring-object bean="SoapHeaderCreatorBean"/>
</component>
<file:outbound-endpoint path="C:/mule/Online/OUT" responseTimeout="10000" doc:name="Requests"/>
<http:outbound-endpoint exchange-pattern="request-response" address="http://localhost:8080/spring-webservices-sample/endpoints" doc:name="HTTP" method="POST" />
<file:outbound-endpoint path="C:/mule/Online/OUT" responseTimeout="10000" doc:name="Responses"/>
</flow>
It seems that the http:outbound endpoint is giving you a stream and the file outbound endpoint is consuming this. You should put a transformer (such as object-to-string) after the http outbound endpoint so as to make sure that the stream is stored in memory and not consumed before the response is given back to the http inbound endpoint.

Axis2 vs Apache Cxf -- Soap Webservice Client

I have to communicate with a Soap Webservice and currently I am consuming it through a client built using the Java library Axis2, and everything is going well, but I need to migrate this client for Apache CXF because we have other clients through Apache CXF and when we have Axis2 and Apache Cxf in the same classpath we have some conflicts because of different implementations of XmlSchema that both libraries use.
The problem is when using Apache Cxf the response are being sent in html and not soap as you can see through this stacktrace we are receiving:
javax.xml.ws.soap.SOAPFaultException: Response was of unexpected text/html ContentType. Incoming portion of HTML stream: <html>
...
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:157)
...
at org.apache.cxf.interceptor.StaxInInterceptor.handleMessage(StaxInInterceptor.java:84)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:835)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1614)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1504)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1310)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:628)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:565)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:474)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:377)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:330)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)
.. 27 more
I have inspected both request and both seem the same as you can see here:
Axis 2 Request
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Header>
<axis2ns10:login xmlns:axis2ns10="http://auth.smssp.atech.br">LOGIN</axis2ns10:login>
<axis2ns11:password xmlns:axis2ns11="http://auth.smssp.atech.br">PASSWORD</axis2ns11:password>
<axis2ns12:sistema xmlns:axis2ns12="http://auth.smssp.atech.br">SYSTEM</axis2ns12:sistema>
</soapenv:Header>
<soapenv:Body>
<ser:pesquisar xmlns:ns2="http://service.smssp.atech.br">
<ser:numeroCNS>11111111</ser:numeroCNS>
<ser:carregarObjetoCompleto>true</ser:carregarObjetoCompleto>
</ser:pesquisar>
</soapenv:Body>
</soapenv:Envelope>
Apache CXF Request
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<login xmlns="http://auth.smssp.atech.br">LOGIN</login>
<password xmlns="http://auth.smssp.atech.br">PASSWORD</password>
<sistema xmlns="http://auth.smssp.atech.br">SYSTEM</sistema>
</soap:Header>
<soap:Body>
<ns2:pesquisar xmlns="http://domain.smssp.atech.br/xsd" xmlns:ns2="http://service.smssp.atech.br" xmlns:ns3="http://searchFilter.infra.smssp.atech.br/xsd">
<ns2:numeroCNS>11111111</ns2:numeroCNS>
<ns2:carregarObjetoCompleto>true</ns2:carregarObjetoCompleto>
</ns2:pesquisar>
</soap:Body>
</soap:Envelope>
Any idea what the problem can be?
Best Regards,
João

Duplicate namespace prefix in SOAP XML error

We are sending the following SOAP XML to the server
<?xml version="1.0" ?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns2:search xmlns:ns2="http://search.tbx.codegen.it">
<arg0/>
<arg1/>
<arg2 xmlns:ns4="http://criteria.search.tbx.codegen.it" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns4:AccomSearchCriteria">
<adult>1</adult>
...
</arg2>
<arg3>50</arg3>
</ns2:search>
</SOAP-ENV:Body></SOAP-ENV:Envelope>
But server encountrs errors for this as follows
SEVERE: Couldn't create SOAP message due to exception: XML reader error: com.ctc.wstx.exc.WstxParsingException: Duplicate declaration for namespace prefix 'SOAP-ENV'.
at [row,col {unknown-source}]: [1,132]
com.sun.xml.ws.protocol.soap.MessageCreationException: Couldn't create SOAP message due to exception: XML reader error: com.ctc.wstx.exc.WstxParsingException: Duplicate declaration for namespace prefix 'SOAP-ENV'.
at [row,col {unknown-source}]: [1,132]
at com.sun.xml.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:359)
at com.sun.xml.ws.transport.http.HttpAdapter.decodePacket(HttpAdapter.java:318)
Is there any thing wrong with the XML message we are sending (Duplicate namespace prefix 'SOAP-ENV')?
Thank you all in advance

Categories

Resources