1
votes

i created a webservice (ASP.NET) with VisualStudio2010. In this service i have only the HelloWorld function which return the string "HelloWorld".

What i try to do is to call this method (in my web service) in my controller.Application (in eclipse with play 2.0) in order to show the result in index.scala.html page.

I've allready try with WS.Response but it didn't work, this is my code:

 public static Result index() {

     Promise<Response> promise = WS.url("http://localhost:59975/WebService1.asmx/HelloWorld").get();
     return async(promise.map(
                new Function<WS.Response, Result>() {
                    public Result apply(WS.Response response) {
                        return ok("Feed title:" + response.asXml());
                    }
                }
            ));

By the way i'm a new play! user and if someone could explain something about the Function<> it will be good.

If you want more explanation, just ask me. thanks


Hi, Today i get my web service body with the following code:

public static Result index() {
    Promise<Response> promise = WS.url("http://localhost:59975/WebService1.asmx").get();        
    return ok(promise.get().getBody().toString());
}

but now i would try to get the reponse of HelloWorld so i tried :

public static Result index() {
    Promise<Response> promise = WS.url("http://localhost:59975/WebService1.asmx/HelloWorld").get();     
    return ok(promise.get().getBody().toString());
}

i get an error with following stack trace:

  • [InvalidOperationException: Le format demandé n'est pas reconnu pour l'URL se terminant par '/HelloWorld'.]

  • System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response) +569481

  • System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) +212

  • System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) +47

  • System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +203

  • System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +128

  • System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

if some one can explain what i'm doing wrong ? thx.

1

1 Answers

0
votes

I believe the WS class is only a wrapper around Apache's HTTPClient or something similar. Meaning is not the best thing to connect to SOAP web services since you have to manually handle the request/response xml.

What you probably want to use is Apache Axis or Apache CXF to build the stubs for your HelloWorld service.