1 2 Previous Next 17 Replies Latest reply on Jul 18, 2013 11:33 AM by moraleslos Go to original post
      • 15. Re: url encoding in the address box for REST
        moraleslos

        I've looked at this already.

         

        Using your POST example and sending in a JSON string directly, how will the REST interface look like?

        • 16. Re: url encoding in the address box for REST
          moraleslos

          Ok, this is what I have and still having problems.  Maybe you can see what I'm doing wrong:

           

          public interface AdminService {

                    String authenticate();

          }

           

           

           

          @Service(AdminService.class)

          public class AdminServiceBean implements AdminService {

           

           

                    @Inject

                    @Reference

                    private InvokeExternalService _ref;

           

                    @Override

                    public String authenticate() {

                              String result =  _ref.authenticate("data={'LoginName':'administrator','Password':'testpassword'}");

           

                              return result;

                    }

          }

           

           

           

          public interface InvokeExternalService {

                    String authenticate(String jsonData);

          }

           

           

           

          @Path("/")

          public interface InvokeExternalReference {

           

           

              @POST

              @Path("Authentication/Authenticate?{jsonString}")

              @Consumes("application/json")

              @Produces({"application/xml","application/json"})

                    String authenticate(@PathParam("jsonString") String jsonString);

           

           

          }

           

           

           

              <sca:reference name="InvokeExternalService" multiplicity="0..1" promote="AdminServiceBean/InvokeExternalService">

                <sca:interface.java interface="com.example.switchyard.switchyard_example.InvokeExternalService"/>

                <resteasy:binding.rest>

                  <resteasy:contextMapper/>

                  <resteasy:messageComposer/>

                  <resteasy:interfaces>com.example.switchyard.switchyard_example.InvokeExternalReference</resteasy:interfaces>

                  <resteasy:address>http://10.64.18.2/item_admin/services/CMS/</resteasy:address>

                </resteasy:binding.rest>

              </sca:reference>

           

           

           

          When I run this I get that aspxerror message like this: 

           

          http://localhost:8080/switchyard-example/authenticate/administrator/testpassword//item_admin/Error/index.htm?aspxerrorpath=/item_admin/services/CMS/Authentication/Authenticate?data={'LoginName':'administrator','Password':'testpassword'}

          • 17. Re: url encoding in the address box for REST
            moraleslos

            The more I look into this, it looks like the json string is being sent correctly, however it seems to lose the external server, i.e. 10.64.18.2.  Not sure if SY is some how flipping back to localhost on invocation based on there error message (notice there is no host).  Any ideas would be appreciated.  Thanks.

            1 2 Previous Next