System.Runtime.Remoting.RemotingException: Requested Service not found - c#

I have the following code in my Web.Config in a remoting project which is having a reference to a dll of another class library. The class library has the following class inside it:
public class Generator: MarshalByRefObject, IGenerator
{
}
When I run the remoting project for the configured uri which is exposing the above class, I get the mentioned error in the question header.
The url I run is this:
http://localhost/documentgenerationserver/Generator.rem
<application>
<service>
<wellknown mode="SingleCall" objectUri="Generator.rem" type="ABC.Generator, Generator" />
</service>
<channels>
<channel ref="http" />
<serverProviders>
<formatter ref="binary" typeFilterLevel="Full" />
</serverProviders>
</channels>
</application>
Can someone advise me, how to resolve this issue?
EDIT 1: After going through an article on remoting on google, I tried appending ?wsdl to my URL above and it worked. It shows me WSDL file for my remote object. In my Client Project which is an asp.net web application hosted in IIS 7.5, when I instantiate the remote object using following:
Activator.GetObject()
It successfully instantiates, but when I use this proxy of remote to call its method, it does not reach up to that method and returns immediately.
Can some one please help me knowing, how can I at least debug it and see, what's happening. Why it is not reaching to the remote object method?

The message "System.Runtime.Remoting.RemotingException: Requested Service not found" is the expected behavior on the browser for a remoting service.

Related

WCF Change baseAddress

Fairly novice to WCF and doing a simple project in VS2017 using the WCF Service Library project template. Name the project MyBlahService and create it. Don't like the default file names Service1.cs and IService.cs so I rename them in the Solution Explorer. This causes some automatic renaming of the IService1 interface and Service1 class. Running from VS started WCF Service Host and WCF Test Client and everything seemed to work OK. Poking around in App.config, I see an entry using 'Service1' like below and change it to the second entry below.
Was:
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/MyBlahService/Service1/" />
</baseAddresses>
Now:
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/MyBlahService/MyBlahSvc/" />
</baseAddresses>
This change broke the service until I went back to Service1. I read all of the other posts that seemed relevant and noticed people had made similar changes, but they didn't explain how they did it. I did a 'grep' of all files in the project and failed to find any other occurrence of 'Service1' so it is a real mystery to me how to use anything other than 'Service1'. Any help?
This has nothing to do with baseAddress. When you rename IService1 and Service1, you also need to modify the service name and contract in the configuration file.
Here is my demo:
I changed IService1 to ITest and I need to change the contract in the configuration file:
Change Service1 to Test:
Feel free to let me know if the problem persists.
UPDATE
Baseadress can be set at will:
<add baseAddress="http://localhost:8733/Test" />
<add baseAddress="http://localhost:8733/Test/Test" />
......
I am accepting Ding Peng's answer because the effort put into it helped me solve the problem. There is something 'magic' about either the Design_Time_Addresses and/or specifying the port. You can put in other addresses easily if you leave both of those out.

Adding ASMX service to IIS for use with Biztalk

I've created a local webservice (.asmx), that I want to add to IIS. The service needs to be called from a Send Adapter in Biztalk.
My project in Visual Studio is structured like so:
There's a single .asmx file, that contains a single web method, see code below:
public class LocalWebService : System.Web.Services.WebService
{
private BankConnectClient client;
[WebMethod]
public void TransferPayment()
{
ProcessDirectory("C:\\Test\\BankConnectTestFiles");
}
I'm not very familiar with IIS, so I don't know best approch to add this service to run on my localhost. I tried adding a new website and placed the project folder in C:\inetpub\wwwroot, which I then reference in IIS with the following settings:
But when I browse to the root http://localhost:61406/, I receive an HTTP Error 403.14.
What is the correct approach in deploying an asmx web service to IIS, to then call in Biztalk using either the WCF-Custom or WCF-BasicHttp adapter?
It seems that the problem has been solved. The service URL need the LocalWebService.asmx suffix.
Besides, as far as I know, BasicHttpBinding in the WCF aims to compatible with ASMX web service, why not try to create a WCF service with BasicHttpBinding. And this is also supported by the BizTalk.
I Have made a demo, wish it is useful to you.
VS template.
Add the following code snippets to the default webconfig.
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
<!--add the following line to support http protocol-->
<add binding="basicHttpBinding" scheme="http"/>
</protocolMapping>
Then publish the project to the IIS folder and add the http binding to the IIS site binding module. We might need to enable the WCF support.
Result.
Feel free to let me know if there is anything I can help with.

Call Soap Service From a Windows Service

I am consuming a Soap service http://example.com/soap/webservice.php in my desktop application . i created a separate class library Included the service and used this class library to consume it in my main application which i working fine.
Here is the code i am using:
MyService.PushServerWSPortTypeClient obj = new MyService.PushServerWSPortTypeClient();
string result = obj.auth(apiId, UserName, Password);
This is working perfect.
But when i use this service in my windows service i am getting the exception:
There was no endpoint listening at http://exmaple.com/soap/webservice.php that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
I know what this exception means that it is unable to find endpoint of it in my service, but in my class library endpoints are mentioned in it's app.config and i also added these endpoints in my windows service app.config as well.
Here is the code from app.config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="PushServerWSBinding" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://example.com/soap/webservice.php"
binding="basicHttpBinding" bindingConfiguration="PushServerWSBinding"
contract="MyService.PushServerWSPortType" name="PushServerWSPort" />
</client>
</system.serviceModel>
Inner Exception Message :
The remote name could not be resolved: 'api.example.com'
Stack Trace :
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
at System.Net.HttpWebRequest.GetRequestStream()
at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream()
It is possible that your browser uses some proxy where your code does not (or use different one).
If it is the case make sure to set WebClient.Proxy property to match one in the browser, making use of the WebProxy class using
WebClient webClient = new WebClient())
{
webClient.Proxy = new WebProxy("myproxy.com");
result= webClient.DownloadString(someURL);
}
If not sure, try out his DNS-Testing link. It is unlikely, but possible if browser uses different DNS than your code.
After digging one complete day,Today we contacted our Networks Department for this weird issue and we came to know that When we use Desktop Application to call any SOAP or WCF Service the request goes through Proxy Server, but in the case of Windows Service the request goes through System Gateway/Firewall and on Firewall port 80 was blocked, due to which the request was unable to call server.
When we opened the port 80 for the service specific url it started wroking normally.

C# client consuming java-websphere SOAP service

I am trying to consume a java-based service from .Net 4.0. (C# Console/Windows Service)
I have added the service reference using VS's Add Service Reference Dialog.
The service is hosted on WebSphere 8 and WSDL definition is generated using cxf.
Client app is running on Windows Server 2008 R2 SP1. But I don't think any windows update is applied after SP1.
Problem is from time to time All the calls to service methods return an exception. The error is as follows:
The content type text/xml;charset=UTF8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8).
If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly.
The first 1024 bytes of the response were: '<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions name="MyServiceImplService" targetNamespace="http://impl.webService.myService.com/" xmlns:ns1="http://webService.myService.com/" xmlns:ns2="http://cxf.apache.org/bindings/xformat" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://impl.webService.myService.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:import location="http://10.1.1.1/myService/webService/myService?wsdl=myService.wsdl" namespace="http://webService.myService.com/"></wsdl:import>
<wsdl:binding name="MyServiceImplServiceSoapBinding" type="ns1:myService">
<soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"></soap12:binding>
<wsdl:operation name="disableCard">
<soap12:operation soapAction="" style="documen'..
Here's my client app's WCF config:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="MyServiceImplServiceSoapBinding">
<textMessageEncoding messageVersion="Soap12" />
<httpTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://10.1.1.1/myService/webService/myService?wsdl"
binding="customBinding" bindingConfiguration="MyServiceImplServiceSoapBinding"
contract="MyServiceReference.myService" name="MyServiceImplPort" />
</client>
</system.serviceModel>
I don't think this has anything to do with WCF configuration since all the methods work fine and all of a sudden, All of them return this exception.
The error seems to show up randomly with no apparent reason. Sometimes after 2 days and ~1,000,000 requests and sometimes after half an hour. But when this exception shows up, every call to the service returns this exception.
On the service side, there's no log that the call even reaches the java application. Seems like WebSphere sends the wsdl definition instead of passing my call to service.
Closing and relaunching the client app does not make the error go away. Only a complete system restart makes the error to disappear. (Update: it seems like removing ?wsdl from the endpoint address, removed the need to restart the system and restarting the client app is enough to make it work again.)
When facing the error, I have called the service methods with Soap UI and got the results with no exception. So there's probably nothing wrong on the service side.
My only guess is that this is a bug in .Net Framework 4.0.
Any help is greatly appreciated.

Confused by use of host name in WSDL file in C# Web Service

I have created a WCF web service in C# deployed in a Windows Service EXE which is largely working the way I want. I am using it in a self-hosted manner (not within IIS).
In order to make a WSDL file available to the calling Java webservice, I added ServiceMetadataBehavior to the host creation. i.e:
ServiceHost host = new ServiceHost(typeof(MyService));
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
host.Description.Behaviors.Add(smb);
host.Open();
This all worked fine until I moved my service to another server with a different host name. When I connect to the WSDL (http://prod-server:55000/MyService?wsdl), I see that the host name of the development server is hard coded in the WSDL.
Here is a snippet of the WSDL as seen in a browser:
<wsdl:definitions name="MyService" targetNamespace="http://tempuri.org/">
<wsdl:import namespace="MyProject.ServiceContracts" location="http://dev-server:55000/MyService?wsdl=wsdl0"/>
<wsdl:types/>
I have checked all of the C# code in the project, and the development server name is not hard coded anywhere.
In the App.config file, I have the following defined:
<system.serviceModel>
<services>
<service name="MyService">
<endpoint address="http://localhost:55000/MyService" binding="basicHttpBinding"
bindingConfiguration="" contract="MyProject.ServiceContracts.IMyInterface" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:55000/MyService" />
</baseAddresses>
</host>
</service>
</services>
I would expect that this would result in the localhost machine name being substituted, but it persists as the development box name on which the service was originally created / deployed. Am I mistaken?
I also looked into the possibility of explicitly specifying a path to my WSDL file, but from what I can deduce, this can only be done if hosting the service on IIS.
Lastly and purely out of curiosity, I wonder if an actual WSDL file actually gets created (a physical file on disk I mean) or is it dynamically rendered with each request?
It is created dynamically, not every call IIRC, but on first request to the metadata endpoint. I'm not sure why your seeing your DEV server name on the non-DEV machine, but, because you're specifying localhost only in your endpoint address it's going to resolve DNS using the primary network address for the server. You may want to consider adding the useRequestHeadersForMetadataAddress behavior to your config so that the DNS with which the service is accessed is actually used instead.
With WCF the WSDL is dynamically generated.
I have had this problem a number of times on a WCF 3/3.5 service when I needed to send a WSDL to someone as a file. Typically what I do is save the files (typically there are 3, a wsdl for the service, an xsd for your types, and an xsd for the .net types, but your mileage may vary), then manually update the wsdl imports to reference the other two files relative to the wsdl file, then send all three files.
The wsdl:service , wsdl:port, and soap:address will still reference the dev server, but most ws client libraries account for this and allow the developer to configure the endpoint.

Categories