i've a custom base controller ,that extend AbstractRestfulController, from which extend other controller of mine web service.
In base controller i've method like this
public function p($text)
{
$oContainer = new Container('locale');
$translate = $this->_oViewHelperManager->get('translate');
return $translate($text, null, $oContainer->szLocale);
}
when i work in local all work fine
my configuration is
ubuntu 14.10
php 5.5.12 as apache module
when i put it in remote server i've got
remote configuration is
php 5.5.9 as fastcgi
Zend\Mvc\Controller\PluginManager::get was unable to fetch or create an instance for p
p as seen like service and not like method
why?
Related
I am trying to setup wiremock under an application path.
I have wiremock dockerized and running under some path https://local.wiremock/ and that works fine, so I can access the admin like this https://local.wiremock/__admin/docs
However when I deploy to aws it needs to be under a path like this:
https://aws-server.wiremock/simulator/__admin/docs
And the addition of the application path /simulator breaks everything.
So I want to set it up locally so that it runs under:
https://local.wiremock/simulator/__admin/docs
I have been going through documentation and there's nothing there for standalone server configuration.
There is a mappedUnder xml field that could be useful but it cannot be set via docker.
Any ideas how to achieve that?
I think you could do this by adding a Request Wrapper. The idea behind the Request Wrapper is that it intercepts the request and allows you to modify it before sending the request on. I think your solution would look something like...
public static class removeSimulatorPath extends StubRequestFilter {
#Override
public RequestFilterAction filter(Request request) {
Request wrappedRequest = RequestWrapper.create()
// lambda to replace the current URL with one without `/simulator`
.transformAbsoluteUrl(url -> url.replace("/simulator", "")
.wrap(request);
return RequestFilterAction.continueWith(wrappedRequest);
}
#Override
public String getName() {
return "remove-simulator-path";
}
}
I have 2 applications, Intranet and Extranet.
The Extranet app does not communicate directly with database, only with web service. The Intranet app is normal with database.
I need use SOAP for communicate with my database, so I have
View -> Controller -> Service -> Entity.
For communicate with service I am using:
[Controller]
$client = new Client("my_soap_address");
$user = $client->test();
[Service]
public function test()
{
$res = $this->em->getRepository("my_entity")->fetchPairs();
return $res;
}
Without SOAP, works perfectly!
With SOAP, returns this error:
Call to a member function getRepository() on a non-object
If my service returns a string, integer or boolean as:
[Service]
public function test()
{
return "is OK";
}
My SOAP works normally.
The problem is any method as getRepository(), getReference(), etc.. But I need these methods for get or put informations from my database.
Please, can anybody help with this problem?
Thanks a lot!
ps.: I have a controller with handleWSDL and handleSOAP between Controler and service.
I solved my problem!
I need send the EntityManager with Soap for the service works.
Let's go:
In my SoapController:
use Path\of\my\service as MyService;
public function handleSOAP($class, $url) {
$soap = new Server($url."?wsdl");
$soap->setClass($class);
$soap->setObject(new MyService($this->getServiceLocator()->get('Doctrine\ORM\EntityManager')));
$soap->handle();
}
For works, I need instance inside setObject Method, my service as I instanced on my Module.php file inside of getServiceConfig().
So, now is ok!
Thanks!
I've read a lot about switching between multiple datasource on runtime, but as far as I understand they're already defined datasources. I'm not quite sure on how can I just asign the datasources properties on runtime from a webservice call.
I don't need to switch between datasources, just need to create only one datasource with conection data coming from a webservice.
Is there a way to retrieve these parameters from the webservice and create the datasource from that?
The policy here is to retrieve the datasource parameters from a webservice for all the projects, that way the connection data is not inside a file nor into the code, and is only manipulated by DBAs from a global security aplication.
I tried to call the web service in the same datasource file, but it didn't work.
Info:
Web service is a Soap Web service
Grails: 1.3.9
Regards.
I think that you can create a BeanPostProcessor that take care of calling your webservice and changing the settings of your dataSource.
Probably you will need to delay the session factory creation, making sure Grails won't try to use your dataSource before you have all setted up correctly.
The BeanPostProcessor will looks like:
class WebserviceDataSourceBeanPostProcessor implements BeanPostProcessor {
Object postProcessBeforeInitialization(Object bean, String beanName) {
return bean
}
Object postProcessAfterInitialization(Object bean, String beanName) {
if (bean instanceof DataSource){
def info = //call webservice here...
bean.username = info.username
bean.password = info.password
bean.url = info.url
//checkout more setters in: http://commons.apache.org/proper/commons-dbcp/apidocs/org/apache/commons/dbcp/BasicDataSource.html
}
return bean
}
}
And make sure you declared this Spring Bean in resources.groovy
beans = {
webserviceDataSourceBeanPostProcessor(WebserviceDataSourceBeanPostProcessor)
}
If you will have more than one project with this same config comming from a webservice you may think in the possibility of a plugin for this, reusing your code.
First, I'm new to Web Services. I have a didactical task at university about developing web application and web service for something like managing distribuited drug stores.
I've developed a working Web Application using struts2 framework, but now I'd like to extend it to a Web Service. I found that I could implement a class (named for example WSManager) which is a wrapper of the various Web App Controllers.
It would have to make calls to static methods of those Controllers. Web Application is designed to provide a Controller for each use case.
for example a Controller is like this:
public class AdminLocaleController extends AbstractController {
private static final long serialVersionUID = -6266455088438602574L;
private static Logger logger = Logger.getLogger(AdminLocaleController.class);
private List<Prodotto> prodotti;
#Override
public String execute() {
prodotti = initializeAdminLocaleView();
return "success";
}
public List<Prodotto> getProdotti() {
return prodotti;
}
public void setProdotti(List<Prodotto> prodotti) {
this.prodotti = prodotti;
}
public static List<Prodotto> initializeAdminLocaleView() {
logger.info("Recupero lista di prodotti da ordinare");
DBController dbController = new DBControllerImpl();
return dbController.getProdottiDaOrdinare();
}
}
and the WSManager class makes a call to the initializeAdminLocaleView(), just like this:
/* AdminLocaleController */
public List<Prodotto> initializeAdminLocaleView(){
return AdminLocaleController.initializeAdminLocaleView();
}
I would create a Web Service in Eclipse providing that service class.
If I'm doing something wrong I ask you the proper way to extend the web application to a web service.
Otherwise, my matter is if I have to (and how to) manage parameters and attributes between Views (jsp) and Controllers.
Finally I have some Controllers (each of these implement SessionAware) which process data and store returned object in Session (for example a LoginController which saves a User bean in request session). Deeper, my question is how I should manage Web App's session stored attributes in case of a Web Service. If I have method calls in WSManager which passes a User bean as parameters, how could I obtain it from a session. Or simply, do I have necessity of obtaining something from a session from a Web Service perspective?
I'm sure I've written a confusionary question, but confusionary is my state of mind at this point too.
For example, I write a simple code, pack it as *.jar and deploy WebService in JBoss, evrything works..
#WebService
#Stateless
public class TestService{
static int takeMePlz = 1;
#WebMethod
public String GetAnsw(String str){
++takeMePlz;
return Integer.toString(takeMePlz);
}
}
So, when i call this web service, takeMePlz static varible increases.
My Serivce has location http://localhost:8080/test_service/TestService,
Now i Want JSP with location: http://localhost:8080/test_service/Administrating,
that has access to my web service, and this JSP should show me takeMePlz static varible in web browser
Create client for webservice
invoke webservice from servlet
catch the result as attribute of request and forward it to jsp and on jsp use JSTL to show the data
In addition, you need to make the takeMePlz field public so it is accessible.
Moreover, you should synchronize access to the field, or make it a java.util.concurrent.atomic.AtomicInteger.
It will still be a bit rough though. Once you have it working, you might want to consider reimplementing using JMX.