Reputation: 27813
I created the following endpoint in my WCF application, that is successfully working (for get calls at least) via GET calls:
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "Search/{platform}/{searchedContentTypeList}/?query={query}&requestedFacetGroupCountList={requestedFacetGroupCountList}&searchedFacetList={searchedFacetList}"
+ "&start={start}&limit={limit}&endpoint={endpoint}&portalId={portalId}&resultMetaIncludeList={resultMetaIncludeList}")]
XosSearchResults Search(string query, string platform, string requestedFacetGroupCountList, string searchedFacetList, string searchedContentTypeList,
int start, int limit, string endpoint, string portalId, string resultMetaIncludeList);
This is running locally on http://localhost/DigitalREST/XosSearch.svc
, as well on our production service. The GET query using the URI template works perfectly fine in a browser, and http://localhost/DigitalREST/XosSearch.svc?wsdl
appears to give the correct meta data.
I then went into my web application, added http://localhost/DigitalREST/XosSearch.svc?wsdl
as a service reference. I then wrote the following code to interact with the service:
var binding = new BasicHttpBinding();
var endpointAddr = new EndpointAddress("http://localhost/DigitalREST/XosSearch.svc?wsdl");
var service = new XosSearchService.XosSearchClient(binding, endpointAddr);
service.Open();
// Run the search
StartIndex = PageSize * SearchPageNum;
SearchResults = service.Search(SearchQuery, Platform, null, FacetSearchString, Constants.VideoContentType, StartIndex, PageSize, Endpoint, PortalId, null);
// Fill generic properties for outside reading
StartIndex = (int)SearchResults.StartIndex;
PageSize = SearchResults.PageSize;
TotalResults = (int)SearchResults.TotalResults;
service.Close();
When the service.Search()
method gets called, the following exception occurs:
There was no endpoint listening at http://localhost/DigitalREST/XosSearch.svc?wsdl that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
The inner exception is:
The remote server returned an error: (404) Not Found.
Even if I take out the ?wsdl
part, I'm still getting this error. What am I doing wrong?
IndexArticles
contract as requested:
[OperationContract]
[WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "IndexArticles/{platform}/{portalId}")]
void IndexArticles(string platform, string portalId);
Upvotes: 0
Views: 1536
Reputation: 1651
It would be benificial to see your endpoint configurations, but it could be a number of different things.
Upvotes: 0
Reputation: 5444
Create a WebHttpBinding instead link. If you cannot find the class, make sure that you have System.ServiceModel.Web referenced
WebHttpBinding binding = new WebHttpBinding()
The current binding, BasicHttpBinding, that you are using is trying to communicate through soap.
Upvotes: 2
Reputation: 2374
I have had problems like this before, what I did was save everything, shut Visual Studio down and then reopen it while running it as an administrator (right click and select run as administrator), give that a try perhaps.
Upvotes: 0