If using samples axis2Server service is very good. But when I created my own web-service using javax I got a problem.
I used wso2 esb 4.60 default configuration
Web service:
import javax.jws.WebParam;
import javax.jws.WebService;
#WebService
public class Lpu {
public boolean scheduleAnAppointment(#WebParam(name = "time") Integer time) {
return true;
}
}
starting web-service:
import javax.xml.ws.Endpoint;
public class Server {
public static void main(String[] args)
{
Endpoint.publish("http://localhost:8090/WebServices/lpu", new Lpu());
}
}
config esb:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://ws.apache.org/ns/synapse">
<sequence name="main">
<in>
<log level="full"/>
<send>
<endpoint>
<address uri="http://localhost:8090/WebServices/lpu"/>
</endpoint>
</send>
</in>
<out>
<log level="full"/>
<send/>
</out>
</sequence>
</definitions>
response:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<axis2ns1:binary xmlns:axis2ns1="http://ws.apache.org/commons/ns/payload">PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxTOkVudmVsb3BlIHhtbG5zOlM9Imh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3NvYXAvZW52ZWxvcGUvIj48UzpCb2R5PjxuczI6c2NoZWR1bGVBbkFwcG9pbnRtZW50UmVzcG9uc2UgeG1sbnM6bnMyPSJodHRwOi8vZmVyLndlYnNlcnZpY2UvIj48cmV0dXJuPmZhbHNlPC9yZXR1cm4+PC9uczI6c2NoZWR1bGVBbkFwcG9pbnRtZW50UmVzcG9uc2U+PC9TOkJvZHk+PC9TOkVudmVsb3BlPg==</axis2ns1:binary>
</soapenv:Body>
</soapenv:Envelope>
I want getting:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:scheduleAnAppointmentResponse xmlns:ns2="http://lpu.webservice/">
<return>true</return>
</ns2:scheduleAnAppointmentResponse>
</S:Body>
</S:Envelope>
my reguest
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fer="http://lpu.webservice/">
<soapenv:Header/>
<soapenv:Body>
<lpu:scheduleAnAppointment>
<time>12</time>
</lpu:scheduleAnAppointment>
</soapenv:Body>
</soapenv:Envelope>
ESB 4.6.0 released with pass through transport, which doesnt build the message. So, if you use the log mediator in the sequence you will get the binary response. But at client end you should receive your response in the preferred format.
If you switch to NIO transport, in the sequence also you can get the actual message payload. For that you need to edit the transport sender and receiver in axis2 configuration(axis2.conf)
Change axis2.xml to axis2_nhttp.xml in
/repository/conf/carbon.xml alter:
<ConfigurationFile>${carbon.home}/repository/conf/axis2/axis2_nhttp.xml</ConfigurationFile>
Another suggestion decrypting the payload:
WSO2 responds payload in binary
Related
We're downgrading our ESB from 5.0.0 to 4.8.1 to match a different development environment and we've hit an unexpected snag: our APIs aren't returning anything.
We were originally using the mediator, which I'm gathering was changed between 4.8.1 and 5.0.0 and cannot in the older version be used as a response so we switched to This is a resource I have set up in an effort to get a smoke test up
<resource methods="GET" uri-template="/StaticTest">
<inSequence>
<log level="full"></log>
<loopback></loopback>
</inSequence>
<outSequence>
<log level="full"></log>
<payloadFactory media-type="json">
<format>{"asdf":"fdsa","blah":3}</format>
<args></args>
</payloadFactory>
<respond></respond>
</outSequence>
</resource>
I know the resource is being hit, because the logging statements make it into the logs. In fact, placing another mediator over the respond tag will display the following
[2017-05-09 15:48:19,968] INFO - LogMediator To: ,
MessageID: urn:uuid:6376072e-d005-497e-b7a1-9f89cff49099,
Direction: response,
Envelope: <?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<jsonObject>
<asdf>fdsa</asdf>
<blah>3</blah>
</jsonObject>
</soapenv:Body>
</soapenv:Envelope>
Which I have taken the liberty of formatting a bit. As you can see a soap envelope has been made matching my static JSON object, but SOAP UI is showing nothing. I get an HTTP 200, but no content. Any idea what could cause this?
When I create proxy with send mediator with Rest service Post HTTP Method in HTTP endpoint url. Selected the endpoint as HTTP endpoint on proxy and post the request xml without soap envelop, this perfectly works and get the response in the response window.
But when I use the call mediator with the same HTTP end point url configuration, this does not works. I would like to know can we use call mediator for Post HTTP method? When I use Call mediator for the GET HTTP method which require only query parameters and does not require any request xml this works absolutely fine.
Here is the further information:
However issue is resloved by using the address endpoint in callmediator. When I Invoke the proxy from external Restt client ot Soap UI, it does works. If I use the Try this Service option in wso2 ESB will fail with the results 1. When Soap12 endpoint is selected and 2 when HTTP end point is selected as shown below.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="postIDMPCall"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<property name="ContentType" value="text/xml" scope="axis2" type="STRING"/>
<property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING"/>
<payloadFactory media-type="xml">
<format>
<organizationList xmlns="">
<xml content>
</organizationList>
</format>
<args/>
</payloadFactory>
<header name="_user" scope="transport" value="username"/>
<header name="_password" scope="transport" value="Password"/>
<call blocking="true">
<endpoint>
<address uri="http://<ip-address>:<port>/<resource-path>/UpdateOrganization"
format="rest"/>
</endpoint>
</call>
</inSequence>
</target>
</proxy>
Output: When soap12 endpoint is selected
Though posted the correct xml service does not recorgonize the correct xml format for soap12 endpoint.
FAILURE
Record is not processed successfully. Please Provide valid Request XML
When Http end point is selected
[2016-04-21 12:07:50,179] INFO - HTTPSender Unable to sendViaPost to url[http://://UpdateOrganization/mediate]
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
I think we can't use call mediator for this purpose because call mediator is context unaware mediator.
Your call should already perform a post out the box.
Did you try to set format="pox" if you expect simple xml as a response
A simple proxy that only adds authentication.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="QueryTestProxy"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property xmlns:ns="http://org.apache.synapse/xsd"
name="Authorization"
expression="fn:concat('Basic ', base64Encode(fn:concat('admin:', wso2:vault-lookup('QueryTest'))))"
scope="transport"
type="STRING"/>
<send>
<endpoint key="conf:/QueryTest"/>
</send>
</inSequence>
<faultSequence>
<send/>
</faultSequence>
</target>
<publishWSDL key="conf:/WSDL/QueryTest.wsdl"/>
<description/>
</proxy>
The endpoint service does a split on CRLF on one of the fields, also the endpoint can not be modified and can't use CDATA.
The problem is that WSO2 ESB always replaces CRLF with LF and the split won't work, does anyone know a way to stop WSO2 ESB to normalize the message?
Axiom uses stax and stax remove those CR in CR-LF
I've had a similar issue when writing text files from a soap message generated like this :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:guid="http://com/cylande/unitedretail/guidedsale/service/common/GuidedSaleManagerService/">
<soapenv:Header/>
<soapenv:Body>
<text xmlns="http://ws.apache.org/commons/ns/payload">my flat datas whith carriage return and line feeds</text>
</soapenv:Body>
</soapenv:Envelope>
We should be able to configure this behavior creating a XMLOutputFactory.properties file inside ESB_HOME, with this content : com.ctc.wstx.outputEscapeCr=false
But in my case, I were not able to start the ESB any more...
(See http://ws.apache.org/axiom/apidocs/org/apache/axiom/om/util/StAXUtils.html for more details)
Here is the javascrip that I've added in my mediation before calling send mediator :
<script language="js"><![CDATA[
try {
var payloadXML = mc.getPayloadXML();
var envelopeXML = mc.getEnvelope();
if (payloadXML != null) {
var text = payloadXML.toString();
if ((envelopeXML != null) && (envelopeXML.getBody() != null) && (envelopeXML.getBody().getFirstElement() != null))
// Do not use mc.setPayloadXML(), it depends on Stax that delete the carriage return we are trying to add...
envelopeXML.getBody().getFirstElement().setText(text.replace(new RegExp('\n','g'),'\r\n'));
}
} catch (e) {
}
]]></script>
Hope you will be able to adapt this script to your need.
ESB's XML parser (AXIOM) is just working according to XML specification
http://www.w3.org/TR/REC-xml/#sec-line-ends
So XML parser must replace CR-LF with LF. This is mentioned in above XML spec .
This is the reason of replacing CRLF with LF in wso2 ESB
I have deployed a WSO2 ESB Proxy Service that works well: it sends a request for a dataset, in the outSequence of the proxy service I send response in a file (I set a sequence for doing it) and i can also visualize response in SOAP UI (or in the "try this service" page of the ESB).
If I set a scheduled task it doesn't work: i set message (my xml right-working message in SOAP UI), injectTo (proxy), proxyName (my proxy name), format (my format) and SoapAction...
I'm sure that the name of SoapAction is correct, but the response of the server is "HTTP header value is not recognized by the server SOAPAction: xxxx" where xxxx is the right soap action name.
This happens with another task i've tried using another simpler proxy service, everything is correct until I use the proxy service within a scheduled task.
I can't understand.
You must be add "soapAction" header like this:
<property name="Code" value="1234"/>
<header name="soapAction" scope="transport" value="http://tempuri.org/MyService/GetAddress"/>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:GetAddress>
<tem:Code>$1</tem:Code>
</tem:GetAddress>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg evaluator="xml" expression="get-property('Code')"/>
</args>
</payloadFactory>
<send>
<endpoint>
<address format="soap11" uri="http://192.168.1.1/Services/ShakouriService.svc?wsdl"/>
</endpoint>
</send>
Check whether you receive this error in the insequence or the outsequence..
Plus, when you send a response back are you using <send/> or providing a specific endpoint.
I have this scenario:
I consume some information from a data service and another information from another data service and I want to merge this two information in a unique response.
In this test I don´t use the data services, I use mock services in SOAPUI and both mock services work fine separately .
The data I want to merge, an example:
Data service 1 response:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:obt="http://informatizacion.uci.cu/servicios/assets/ObtenerPersonas">
<soap:Header/>
<soap:Body>
<obt:Personas>
<!--Zero or more repetitions:-->
<obt:Persona>
<obt:idExpediente>T123654</obt:idExpediente>
<obt:primerNombre>yanaka</obt:primerNombre>
<obt:primerApellido>perez</obt:primerApellido>
<obt:segundoApellido>perez</obt:segundoApellido>
<obt:sexo>F</obt:sexo>
<obt:ci>920125848</obt:ci>
<obt:provincia>ok</obt:provincia>
<obt:municipio>yes</obt:municipio>
<obt:area>facultad</obt:area>
<obt:esDocente>false</obt:esDocente>
</obt:Persona>
</obt:Personas>
</soap:Body>
</soap:Envelope>
Data service 2 response:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:preg="http://pregrado.uci.cu">
<soap:Header/>
<soap:Body>
<preg:Personas>
<!--Zero or more repetitions:-->
<preg:Persona>
<preg:idExpediente>11111</preg:idExpediente>
<preg:primerNombre>jorge</preg:primerNombre>
<preg:primerApellido>infante</preg:primerApellido>
<preg:segundoApellido>osorio</preg:segundoApellido>
<preg:sexo>M</preg:sexo>
<preg:ci>1221122112211221</preg:ci>
<preg:provincia>rdf</preg:provincia>
<preg:municipio>dsf</preg:municipio>
<preg:area>df</preg:area>
<preg:esDocente>true</preg:esDocente>
</preg:Persona>
<preg:Persona>
<preg:idExpediente>gero et</preg:idExpediente>
<preg:primerNombre>sonoras imperio</preg:primerNombre>
<preg:primerApellido>quae divum incedo</preg:primerApellido>
<preg:segundoApellido>verrantque per auras</preg:segundoApellido>
<preg:sexo>per auras</preg:sexo>
<preg:ci>circum claustra</preg:ci>
<preg:provincia>nimborum in</preg:provincia>
<preg:municipio>foedere certo</preg:municipio>
<preg:area>profundum quippe ferant</preg:area>
<preg:esDocente>false</preg:esDocente>
</preg:Persona>
</preg:Personas>
</soap:Body>
</soap:Envelope>
So I build this proxy service:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="PersonaPoC"
transports="https,http" statistics="disable" trace="disable"
startOnLoad="true">
<target inSequence="conf:/PersonaPoC/obtener_estudiantes"/>
<publishWSDL key="conf:/wsdl/PersonaSimplev2.wsdl"/>
<description></description>
</proxy>
With this sequences:
Name: obtener_estudiantes.
<sequence xmlns="http://ws.apache.org/ns/synapse">
<payloadFactory>
<format>
<preg:ObtenerEstudiantesPoC xmlns:preg="http://pregrado.uci.cu"/>
</format>
</payloadFactory>
<send receive="conf:/PersonaPoC/guardar_Estudiantes">
<endpoint>
<address uri="http://destrono:8088/mockPregradoWSSOAP12Binding/"/>
</endpoint>
</send>
</sequence>
Name: guardar_Estudiantes.
<sequence xmlns="http://ws.apache.org/ns/synapse">
<enrich>
<source clone="false" type="body"/>
<target action="replace" type="property"
property="listado_estudiantes"/>
</enrich>
<payloadFactory>
<format>
<obt:ObtenerPersonasPoC
xmlns:obt="http://informatizacion.uci.cu/servicios/assets/ObtenerPersonas"/>
</format>
</payloadFactory>
<log level="full"/>
<send receive="conf:/PersonaPoC/unir_Personas">
<endpoint>
<address uri="http://destrono:8888/mockAssetsSOAP12Binding"/>
</endpoint>
</send>
</sequence>
At this point I see this error in the ESB when execute the service:
This is a log of the message send to the second service, mockAssetsSOAP12Binding. I don´t know why appear this namespace:
xmlns:preg=http://pregrado.uci.cu in the request because I don´t used it in the payloadfactory mediator.
[2013-04-10 20:17:17,303] INFO - LogMediator To:
http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: ,
MessageID: urn:uuid:26b0c552-d8e6-4285-8814-84c595dae544, Direction:
response, Envelope:
<?xml version='1.0' encoding='utf-8'?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:preg="http://pregrado.uci.cu">
<soap:Body>
<obt:ObtenerPersonasPoC
xmlns:obt="http://informatizacion.uci.cu/servicios/assets/ObtenerPersonas"/>
</soap:Body>
</soap:Envelope>
The error:
[2013-04-10 19:49:30,472] ERROR - RelayUtils Error while building Passthrough stream
org.apache.axiom.soap.SOAPProcessingException: Transport level information does not match with SOAP Message namespace URI
at
org.apache.axis2.builder.BuilderUtil.validateSOAPVersion(BuilderUtil.java:77
4)
at
org.apache.axis2.builder.SOAPBuilder.processDocument(SOAPBuilder.java:58)
at
org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocumen
t(DeferredMessageBuilder.java:146)
at
org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUti
ls.java:150)
at
org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtil
s.java:91)
at
org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediat
or.java:62)
at
org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.
java:114)
at
org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2Syn
apseEnvironment.java:223)
at
org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseC
allbackReceiver.java:443)
at
org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbac
kReceiver.java:166)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at
org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:217
)
at
org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerP
ool.java:172)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:11
10)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:6
03)
at java.lang.Thread.run(Thread.java:722)
when I used the data services in AS 5.1.0 I saw this error:
org.apache.axiom.soap.SOAPProcessingException: First Element must contain the local name, Envelope , but found faultstring
If I put the TCPMon I can see this message exchange:
Incoming message:
POST /mockAssetsSOAP12Binding HTTP/1.1
Content-Encoding: gzip
Content-Type: application/soap+xml; charset=UTF-8
Server: Jetty(6.1.x)
Transfer-Encoding: chunked
Host: 127.0.0.1:8888
Connection: Keep-Alive
124
<?xml version='1.0' encoding='UTF-8'?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:preg="http://pregrado.uci.cu"><soap:Body>
<obt:ObtenerPersonasPoC
xmlns:obt="http://informatizacion.uci.cu/servicios/assets/ObtenerPersonas"/>
</soap:Body></soap:Envelope>
0
Outgoing message:
HTTP/1.1 500 Internal Server Error
Content-Type: text/html; charset=iso-8859-1
Transfer-Encoding: chunked
Server: Jetty(6.1.x)
1a0
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<soap:Fault>
<soap:Code>
<soap:Value>Server</soap:Value>
</soap:Code>
<soap:Reason>
<!--1 or more repetitions:-->
<soap:Text xml:lang="en">java.io.IOException: Decompression of response failed</soap:Text>
</soap:Reason>
</soap:Fault>
</soap:Body>
</soap:Envelope>
0
This is the last sequence.
Name: unir_Personas.
<sequence xmlns="http://ws.apache.org/ns/synapse">
<enrich>
<source clone="false" type="body"/>
<target action=" sibling" type="property"
property="listado_estudiantes"/>
</enrich>
<send/>
</sequence>
Any idea?
I don´t know why appear this namespace:
xmlns:preg=http://pregrado.uci.cu in the request because I don´t used
it in the payloadfactory mediator.
You might get that from your endpoint's response. You are using payload only for body and that particular namespace appears at rootlevel. Anyway, that is not the cause for the issue you are facing. In the middle you mentioned about SOAP12 service . Check the namespace is right, and if your endpoint accepts SOAP 12 requests, change the endpoint format to soap12