To get the message count from topic, I have invoked the WSO2 MB 3.1.0 AdminService api calls. It worked for queue but not for the topic. When invoking with topic, it doesn't give the correct count (it always gives 0)
(To show the message count in topic in WSO2 MB Management console, I have created an inbound endpoint with suspend state in WSO2 ESB and created a durable subscription to the topic)
Get Message Count from queue.
url:https://localhost:9447/services/AndesAdminService.AndesAdminServiceHttpsSoap12Endpoint
Request body:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://wso2.org/carbon/andes/admin/xsd">
<soap:Header/>
<soap:Body>
<xsd:getMessageCount>
<!--Optional:-->
<xsd:destinationName>test-queue</xsd:destinationName>
<!--Optional:-->
<xsd:msgPattern>**queue**</xsd:msgPattern>
</xsd:getMessageCount>
</soap:Body>
</soap:Envelope>
Get Message Count from topic.
url:https://localhost:9447/services/AndesAdminService.AndesAdminServiceHttpsSoap12Endpoint
Request body:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://wso2.org/carbon/andes/admin/xsd">
<soap:Header/>
<soap:Body>
<xsd:getMessageCount>
<!--Optional:-->
<xsd:destinationName>mytopic</xsd:destinationName>
<!--Optional:-->
<xsd:msgPattern>**topic**</xsd:msgPattern>
</xsd:getMessageCount>
</soap:Body>
</soap:Envelope>
I set the messagePattern as "topic" to get the message count in the topic. Is this not correct? If so whats the correct way of getting the message count in a topic using Admin services.
Reference:
https://docs.wso2.com/display/MB310/Calling+Admin+Services+from+Apps
There is no way to get message count of topics. Topics are supposed to be real time and there is no meaning to a message count in a "topic".
However, if you are looking for a message count remaining in a "durable topic", you can pass below information and get the message count.
queuename = carbon:{subscription ID}
, msgPattern = queue
Relevant code
public long getMessageCount(String queueName, String msgPattern) throws MBeanException {
if (log.isDebugEnabled()) {
log.debug("Counting at queue : " + queueName);
}
long messageCount = 0;
try {
if (!DLCQueueUtils.isDeadLetterQueue(queueName)) {
if ("queue".equals(msgPattern)) {
messageCount = Andes.getInstance().getMessageCountOfQueue(queueName);
}
} else {
messageCount = Andes.getInstance().getMessageCountInDLC(queueName);
}
} catch (AndesException e) {
log.error(MESSAGE_COUNT_RETRIEVE_ERROR + queueName, e);
throw new MBeanException(e, MESSAGE_COUNT_RETRIEVE_ERROR + queueName);
}
return messageCount;
}
Related
I'm trying to send a SOAP Request to a webservice in Delphi XE5. Actually there is a WSDL available which I imported via WSDL Importer. I established a connection to this webservice with the components THTTPRIO (rio) and IdEncoderMIME1 for the HTTP Authentication Request.
The SOAP Request was build via TXMLDocument and has the following structure:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cod=NS_Codelist>
<soapenv:Header/>
<soapenv:Body>
<cod:GetLatestChangeDatesRequest>
<!--Zero or more repetitions:-->
<CodeListID>1035</CodeListID>
</cod:GetLatestChangeDatesRequest>
</soapenv:Body>
</soapenv:Envelope>
Furthermore I received the Porttype of the webservice.
codeserv:= GetCodeListPortType(true,'',rio);
These are methods from the WSDL:
codeserv.GetLatestChangeDates(const body:GetLatestChangeDatesRequestType):GetLatestChangeDatesResponseType
GetLatestChangeDatesRequestType = array of Int64;
GetLatestChangeDatesRequest = GetLatestChangeDatesRequestType;
GetLatestChangeDatesResponseType = array of CodeListLatestChangeDateType;
GetLatestChangeDatesResponse = GetLatestChangeDatesResponseType;
CodeListLatestChangeDateType
property CodeListID: Int64
property LatestChangeDate: TXSDate
I have already tried to set an array of Int64 for the parameter but then it says "element CodeListID is missing".
Unfortunately I don't find a way to send this XML SOAP Request to the webservice and to receive the response. Any ideas?
EDIT: I have tried to use the WSDL methods
var
codeserv: CodeListPortType;
arrIDs: GetLatestChangeDatesRequest;
response: GetLatestChangeDatesResponse;
begin
codeserv:= GetCodeListPortType(true,'',rio);
SetLength(arrIDs,1);
arrIDs[0]:= 1035;
response:= codeserv.GetLatestChangeDates(arrIDs);
But then I receive the following error message: 'invalid content was found starting with element 'long'. One of '{CodeListID}' is expected.'
In the SOAP Request there have to be the element CodeListID. Unfortunately it seems the method GetLatestChangeDates isn't creating the elements in the SOAP Request. The SOAP Request posted above should have been created with this method (hopefully).
I want to set the value of token in this soap ws header
<soapenv:Enveloppe ...
<soapenv:Header>
<web:token>123456 </web:token>
FROM step named test get idSession in response
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns1:authentification xmlns:ns1="http://ws.demowebservices.com/">
<bloc1>
<bloc2>
<idSession>e1c64cd9-b933-4f56-ae1f-0f7d7f23942b</idSession>
</bloc2>
I tried to put in-between web:token tag
${test#Response#//ns1:authentification/bloc1/bloc2/idSession}
but it does not work
What should I put instead ?
I'm not sure if this is what you're trying to achieve, however If you have a SOAP Test step called Test Request and you want to use the value of the <soapenv:Header><web:token></soapenv:Header> of this request in another SOAP Test step you can refer this value in the second SOAP Test step request using the follow syntax:
<soapenv:Enveloppe ...
<soapenv:Header>
<web:token>${Test Request#Request#//soapenv:Header/web:token}</web:token>
The syntax ${Test Request#Request#//soapenv:Header/web:token} has three parts, the name of the test step, followed by the property (could be #Request or #Response), and finally the xpath to get the value //soapenv:Header/web:token.
UPDATED:
As you said you've two SOAP Test Request, the first one is called test an has the follow response:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns1:authentification xmlns:ns1="http://ws.demowebservices.com/">
<bloc1>
<bloc2>
<idSession>e1c64cd9-b933-4f56-ae1f-0f7d7f23942b</idSession>
</bloc2>
</bloc1>
</ns1:authentification>
</soap:Body>
</soap:Envelope>
The second is named for example test 2 (don't care because the second name not affect your purpose) and has the follow request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<web:token>${test#Response#//ns1:authentification/bloc1/bloc2/idSession}</web:token>
</soapenv:Header>
<soapenv:Body>
...
</soapenv:Body>
</soapenv:Envelope>
With ${test#Response#//ns1:authentification/bloc1/bloc2/idSession} you're referencing the idSession value of the test response correctly. Take a look on the http log tab when you send your test 2 as shown in the follow image:
Hope this helps,
I'm trying to create a simple WS proxy using Switchyard 1.1 with Camel:
--> PromotedService --> Camel --> ProxifiedService
With the current configuration I'm able to send and recieve messages without any problem.
However, when the ProxifiedService throws a SoapFault it is not propagated to the caller of the PromotedService.
What can I do to ensure the the PromotedServiceCaller receives the SOAPFault as reponse?
This is what I have tried so far:
onException(Exception.class)
.process(
new Processor() {
public void process(Exchange exchange) throws Exception {
SoapFault fault = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, SoapFault.class);
System.out.println("Fault: " + fault); // --> This returns NULL
Exception excep = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);
System.out.println("excep: " + excep);
System.out.println("excep message: " + excep.getMessage());
System.out.println("excep cause: " + excep.getCause());
SoapFault SOAP_FAULT = new SoapFault(excep.getMessage(), SoapFault.FAULT_CODE_CLIENT);
Element detail = SOAP_FAULT.getOrCreateDetail();
Document doc = detail.getOwnerDocument();
Text tn = doc.createTextNode("this is a test");
detail.appendChild(tn);
exchange.getOut().setFault(true);
exchange.getOut().setBody(SOAP_FAULT);
exchange.setProperty(Exchange.ERRORHANDLER_HANDLED, false);
exchange.removeProperty("CamelExceptionCaught");
}
})
.handled(true)
.end();
from("switchyard://PromotedService")
.process(myProc) // --> I just add some headers here to the original request.
.handleFault()
.to("switchyard://ProxifiedService").end();
This is the SOAPFault generated by the ProxifiedService:
<soapenv:Envelope xmlns:ser="http://service.admin.ws.my.company/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
</soapenv:Header>
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server</faultcode>
<faultstring>Missing valid token.</faultstring>
</soapenv:Fault>
</soapenv:Body>
And this the message the caller is really receiving:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header/>
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>org.switchyard.HandlerException: org.apache.cxf.binding.soap.SoapFault: javax.xml.transform.dom.DOMSource#663dcb96</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
Thank you!
onException() only takes Throwable. In your code the argument is SoapFault which is not Throwable.
This will work
onException(SOAPException.class)
I have a web service running on my local apache tomcat. I can successfully talk to it via SoapUI. However, when I write a client in Java, it does not give me a response !
Here is the client code:
SOAPConnectionFactory myFct = SOAPConnectionFactory.newInstance();
SOAPConnection myCon = myFct.createConnection();
MessageFactory myMsgFct = MessageFactory.newInstance();
SOAPMessage message = myMsgFct.createMessage();
SOAPPart mySPart = message.getSOAPPart();
SOAPEnvelope myEnvp = mySPart.getEnvelope();
SOAPBody body = myEnvp.getBody();
Name bodyName = myEnvp.createName("Ping", "ws","http://ws.myeclipseide.com/");
SOAPBodyElement gltp = body.addBodyElement(bodyName);
Name myContent1 = myEnvp.createName("arg0");
SOAPElement mySymbol1 = gltp.addChildElement(myContent1);
mySymbol1.addTextNode("test");
message.saveChanges();
URLEndpoint endPt = new URLEndpoint("http://localhost:8080/PingWebService/StringPingPort?WSDL");
SOAPMessage reply = myCon.call(message, endPt);
myCon.close();
System.out.println("Response: "+reply.getContentDescription());
The call through soapUI looks like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.myeclipseide.com/">
<soapenv:Header/>
<soapenv:Body>
<ws:Ping>
<!--Optional:-->
<arg0>testing this</arg0>
</ws:Ping>
</soapenv:Body>
</soapenv:Envelope>
Any idea why it would not work through java???
Does not work
Exception, error message, no call,... ?
At first glance, I cannot see anything obvious but since you are using Eclipse, activate the TCP Monitor under Eclipse, issue your call by running you program from Eclipse and check what is sent on the wire.
getContentDescription() "Returns: a String describing the content of this message or null if no description has been set" and NOT the content of your message.
Try this:
ByteArrayOutputStream out = new ByteArrayOutputStream();
reply.writeTo(out);
System.out.println("Response: "+out.toString());
I am testing a webservice method which accepts session-id as a parameter.
While testing the same method via SoapUI with a dummy sessionID-Parameter, the server is rejecting the request as it is expecting proper session-id.
How can I solve this? Is there any way where SoapUI can bind the session-id before sending the request?
Please advice me. Thanks
Below is the sample-request which is triggered from SOAP-UI:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.local.com">
<soapenv:Header/>
<soapenv:Body>
<ser:getMultiple>
<!--Optional:-->
<ser:sessionId>1000AJHEFG0987</ser:sessionId>
<!--Optional:-->
<ser:lessonId>95101</ser:lessonId>
<!--Optional:-->
<ser:quantity>1</ser:quantity>
<!--Optional:-->
<ser:impressionRow>1</ser:impressionRow>
</ser:getParametersMultiple>
</soapenv:Body>
</soapenv:Envelope>
Let's say, if you get sessionid in first request's response, and the next request should go here http://{{original endpoint}}/{{SESSION_ID}}), this definitely works:
go to request (not the test request inside test case) where session id should be put into
add a parameter on 'request' tab
name=sessionid, style=template, level=resource. now it is empty in all related test requests
go to test request, 'request' tab
put the path to sessionid value from previous request into 'value' field of sessionid parameter. for example, it is like ${users#Response#$.session_id} where 'users' is the name of endpoint resource, 'session_id' is the name of parameter inside response
Found the solution,
Design your login method which will accept certain inputs and will
return the sessionID as a string
Hit that login method from SOAP-UI and you will get the sessionID in
your response
Use "Property Transfer" option in soap-ui and transfer the received
sessionID to all other requests
Helpful Link : soapui.org/Functional-Testing/transferring-property-values.html
Simple !! :)