0

I'm not very good with angular. I want to post to a web service, sending some xml with my search parameters. I don't want to send the parameters in the query string. I've read the official documentation, but I'm still confused. I'm mostly hung up on how to define the $resource to be able to post the way I want.

The error I get is: POST 'https://someWebservice/searchnet'::ERR_INSECURE_RESPONSE

My code is below:

'use strict';
    angular.module('app').controller('inventorySearchController', inventorySearchController);

    inventorySearchController.$inject = ['$scope','$http', '$resource'];


    function inventorySearchController($scope, $http, $resource) {
        console.log("controller initialized...");



        $scope.callService = function(){
            console.log("callService function called...");
            var urlSearchService = 'https://someWebservice/search';
            var skuVal = $scope.skuField;
            var mVenVal = $scope.mVendorField;
            //need to somehow specifiy that xml is a @FormParam
            var xmlItemSearchRequest = "<ItemSearchRequest>"
                                            +"<skuid>" + skuVal + "</skuid>"
                                            +"<mvendor>" + mVenVal + "</mvendor>"
                                        +"</ItemSearchRequest>";

            console.log('calling: ' + urlSearchService + 'sending xml: ' + xmlItemSearchRequest);

            var Results = $resource(urlSearchService, {
                save: {
                    method: 'POST',
                    isArray: true
                    }
            });
            var result = Results.save();

            console.log('Results: ' + Results);
            console.log('result: ' + result);

            var successfunction =  function(){
                $scope.searchResults = data;
                console.log('call to ' + urlSearchService + ", was a success.");
            };

            var errorfunction = function(){
                console.error('Calling error', status, data);
            };


        };

    };
Accribus
  • 150
  • 14

1 Answers1

0

The error shown is not about how you posted data. Instead, response was not signed by a valid SSL certificate (or the certificate could not be accepted). That is due to the use of HTTPS protocol. You should consider using HTTP instead.

You can try the approach suggested here to confirm that this is the case.

Community
  • 1
  • 1
kubuntu
  • 2,525
  • 1
  • 22
  • 24
  • Ok, using HTTP I get a 415 error "unsupported media type" any ideas? – Accribus Sep 18 '15 at 19:57
  • Have you checked if data is actually transferred to your server? It may also have to do with the endpoint implementation on your server. What are you using on server-side? See this http://stackoverflow.com/questions/11492325/post-json-fails-with-415-unsupported-media-type-spring-3-mvc – kubuntu Sep 19 '15 at 01:49