Your application rejects requests with Content-Type different than "text/xml".
Can you add this workaround in the EndPoint Service (line 51):
@Consumes({MediaType.TEXT_XML, "application/soap+xml"})
This will allow to process "application/soap+xml" requests correctly instead of generating the 415 HTTP error.
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yeah, thanks for suggestion. Although most of the SOAP clients I tried so far send rquests of type "text/xml" but you are right, I'll include the "application/soap+xml" media type in the next release.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Are you planning to support nested resources for REST WS?
I would find helpful something like:
* http://server:port/mock/endpoint/{SERVICE[i].TYPE}/{SERVICE[i].NAME}/{RESOURCE_ID[0]}/{RESOURCE_ID[1]}.../{RESOURCE_ID[N]}
or
Thanks for your post.
I understand your suggestion is closer to the nature of real RESTful webservices, however I'm trying to keep the whole thing simple so for know each nested resource of a real RESTful webservice is supposed to be mocked as a separate SERVICE[]. You can configure multiple services and each of the will have a separate URL.
Anyway, could you elaborate a bit more? Is there any use case in your tests you are not able to address with the current API?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry for the late answer.
If your links are dynamically constructed it probably won't be possible to use my service. You cant compose service names with '/'.
It's probably something I'd have to look at.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I don't have much experience on SOAP based services. I am currently working on REST webservices. Could you please give me sample example on how to configure the details for REST based services.
Thanks in advance!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I liked this idea and implementation. But the problem is in my case the mock response is in Json. But this app always gives the content-type as application/xml. Which is a issue for us. I did some change in the code so you can also specify something like "SERVICE[0].OPERATION[0].DEFAULT_RESPONSE_CONTENT_TYPE=application/json"
which is used to setup content type.
I have changes on my machine let me know if you would like to have a look and commit.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for your interest in the project and the improvement suggestion.
Your are right, we should add something like this.
I've added you to the developers list, feel free to create a branch and submit your code.
Alternatively you can send me a patch.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Recorded requests are still wrapped in a recorded-requests xml tag no matter what types of requests have actually been sent.
I'm planning to re-implement all verification resources:
/recorded-requests
/recorded-resource-ids
/recorded-request-params
so that they respond with a content type based on Accept HTTP header sent to them.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry for my bad english.
I deploy a test application with your project, but I do not understand how to change the response of the WS dynamically.
I need to programmatically change the reply that "Mock" me back. Now I can only return to the answer that I set in the file response.xml, when I edit the file with an editor response.xml "Mock" does not seem to feel the difference and gives me back the old contents of the response file. xml.
can you please post an example of code for a change of the response programmatically?
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you want to setup response programatically you need REST API of the mock service. So first send POST request to the /init resource
and the send your custom response to /responses resource.
you can check exact links to those resources by inspecting this url:
Thank you for the response!
Another question, if you don't mind:
Is it possible to map a request to a response, or I can only set sequential list of responses for a method?
Thanks!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am new to the overall concept of "mocking the rest services", therefore, I have one confusion. The mocker works fine for the GET request, but would it actually DELETE, POST or PUT something when these headers are used? Or would the response be just a message telling that the particular item has been deleted successfully?
Thanks!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Your second guess is right. The mock would tell you that it received a request.
In case of POST and PUT you could also get request body (xml or json) so you could build test assertions basing on that.
If you are familiar with unit testing with Mockito then this is somehow analogous to .verify() when you check a mock object if some method has been invoked on it and with what parameters.
Last edit: Jacek Obarymski 2014-08-18
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thankyou. Now it makes sense. So, the mocker will just "mock" the response that the particular item has been deleted/posted/updated in the database but in reality, no such thing would happen. I am familiar with the request body idea that you mentioned and how you can decide whether you want json content or xml.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm preparing an RC version. Feel free to suggest any improvements. Do you find the app usefull? Any feedback apreciated
Hello, I have a small suggestion.
Your application rejects requests with Content-Type different than "text/xml".
Can you add this workaround in the EndPoint Service (line 51):
@Consumes({MediaType.TEXT_XML, "application/soap+xml"})
This will allow to process "application/soap+xml" requests correctly instead of generating the 415 HTTP error.
Thanks.
Yeah, thanks for suggestion. Although most of the SOAP clients I tried so far send rquests of type "text/xml" but you are right, I'll include the "application/soap+xml" media type in the next release.
Are you planning to support nested resources for REST WS?
I would find helpful something like:
* http://server:port/mock/endpoint/{SERVICE[i].TYPE}/{SERVICE[i].NAME}/{RESOURCE_ID[0]}/{RESOURCE_ID[1]}.../{RESOURCE_ID[N]}
or
Hi Gonzlao,
Thanks for your post.
I understand your suggestion is closer to the nature of real RESTful webservices, however I'm trying to keep the whole thing simple so for know each nested resource of a real RESTful webservice is supposed to be mocked as a separate SERVICE[]. You can configure multiple services and each of the will have a separate URL.
Anyway, could you elaborate a bit more? Is there any use case in your tests you are not able to address with the current API?
Sure, here is the use case that I'm trying to implement:
This is the "ws-mock.properties" configuration:
SERVICE[0].NAME=element
SERVICE[0].TYPE=REST
SERVICE[0].OPERATION[0].HTTP_METHOD=GET
I configure my application using this URL:
http://localhost:8080/das-mock/endpoint/REST
And the url that the application tries to use is:
http://localhost:8080/das-mock/endpoint/REST/data-access/element/BasicAction
Where
- data-access is the name of the service
- element is the name of a method
- BasicAction is a @Param of this method
I think it will work for me, if it is possible to specify a name composed with '/'.
E.g: SERVICE[0].NAME=data-access/element
Should you have any questions or suggestions, let me know.
Hi Gonzlao,
Sorry for the late answer.
If your links are dynamically constructed it probably won't be possible to use my service. You cant compose service names with '/'.
It's probably something I'd have to look at.
Hi,
I don't have much experience on SOAP based services. I am currently working on REST webservices. Could you please give me sample example on how to configure the details for REST based services.
Thanks in advance!
Poorna,
Have a look at the API section, there's and example of REST service configuration:
https://sourceforge.net/p/soaprest-mocker/wiki/api/
Hi Jacek,
I liked this idea and implementation. But the problem is in my case the mock response is in Json. But this app always gives the content-type as application/xml. Which is a issue for us. I did some change in the code so you can also specify something like "SERVICE[0].OPERATION[0].DEFAULT_RESPONSE_CONTENT_TYPE=application/json"
which is used to setup content type.
I have changes on my machine let me know if you would like to have a look and commit.
Hi Rajeev
Thanks for your interest in the project and the improvement suggestion.
Your are right, we should add something like this.
I've added you to the developers list, feel free to create a branch and submit your code.
Alternatively you can send me a patch.
OK, I've fixed it in the 1.3.0 release.
Hi Jacek,
Thanks for fixing the issue. Does the recoding request feature work for application/json type. I tried but no luck.
Thanks,
Rajeev
Hi Rajeev,
Recorded requests are still wrapped in a recorded-requests xml tag no matter what types of requests have actually been sent.
I'm planning to re-implement all verification resources:
/recorded-requests
/recorded-resource-ids
/recorded-request-params
so that they respond with a content type based on Accept HTTP header sent to them.
Hi,
Sorry for my bad english.
I deploy a test application with your project, but I do not understand how to change the response of the WS dynamically.
I need to programmatically change the reply that "Mock" me back. Now I can only return to the answer that I set in the file response.xml, when I edit the file with an editor response.xml "Mock" does not seem to feel the difference and gives me back the old contents of the response file. xml.
can you please post an example of code for a change of the response programmatically?
Thanks
Hi,
If you want to setup response programatically you need REST API of the mock service. So first send POST request to the /init resource
and the send your custom response to /responses resource.
you can check exact links to those resources by inspecting this url:
http://server:port/{mock-context}/services e.g.
http://localhost:8080/mock/services
You can download the sample project and look at the integration tests code there:
https://sourceforge.net/projects/soaprest-mocker/files/examples/
You can also have a look at integration tests in this project:
SOAP:
https://github.com/jaceko/cxf-circuit-switcher/blob/master/src/test/java/com/github/jaceko/circuitswitcher/it/jaxws/JaxwsFailoverIntegrationTest.java
REST:
https://github.com/jaceko/cxf-circuit-switcher/blob/master/src/test/java/com/github/jaceko/circuitswitcher/it/jaxrs/JaxrsFailoverIntegrationTest.java
Last edit: Jacek Obarymski 2013-11-12
Hi,
I don't use MAVEN project but i found some logic difference between my project and example project.
Now my project works!
thanks!
Hi,
Whether it is possible to run Mock Server outside of maven build?
Thanks!
Sure, Just Download the war file from http://sourceforge.net/projects/soaprest-mocker/files/ and deploy it to a servlet container.
Thank you for the response!
Another question, if you don't mind:
Is it possible to map a request to a response, or I can only set sequential list of responses for a method?
Thanks!
Hi Nick,
No, mapping requests to responses is not possible at the moment.
Cheers.
Hi Jacek,
I am new to the overall concept of "mocking the rest services", therefore, I have one confusion. The mocker works fine for the GET request, but would it actually DELETE, POST or PUT something when these headers are used? Or would the response be just a message telling that the particular item has been deleted successfully?
Thanks!
Hi Alina,
Your second guess is right. The mock would tell you that it received a request.
In case of POST and PUT you could also get request body (xml or json) so you could build test assertions basing on that.
If you are familiar with unit testing with Mockito then this is somehow analogous to .verify() when you check a mock object if some method has been invoked on it and with what parameters.
Last edit: Jacek Obarymski 2014-08-18
Thankyou. Now it makes sense. So, the mocker will just "mock" the response that the particular item has been deleted/posted/updated in the database but in reality, no such thing would happen. I am familiar with the request body idea that you mentioned and how you can decide whether you want json content or xml.