I am trying to add a SOAP web service in the VS.NET 2010 interface, but I get that the server refused the connection. The people in charge of the service tell me it is working. I asked if they had a wsdl file, but supposedly they have none.
Is the problem caused by their lack of wsdl, or can I assume there is a problem on my side?
If they are not willing to expose their service metadata on the service then see if they will give you access to the assemblies containing the service contract, operations, and data contracts. Then you can create a proxy to the service without needing any metadata.
// Create service proxy on the fly
var factory = new ChannelFactory<IMyServiceContract>("NameOfMyClientEndpointInConfigFile");
var proxy = factory.CreateChannel();
// Create data contract
var requestDataContract = new MyDataContract();
// Call service operation.
var responseDataContract = proxy.MyServiceOperation(requestDataContract);
It also helps if you have access to the service-side config file so you can copy the endpoint details out of there into your client config.
It looks like their service is not exposing metadata. Try and browse to the wsdl url and see if you get back anything. http://server/blah/blah?wsdl
Related
I am looking at using a ServiceStack web service in place of an existing third-party web service. I have matched the DTOs used by the third-party service. However, the client is expecting a proxy class named "NotificationServiceClient", like this:
var client = new NotificationService.NotificationServiceClient();
var response = client.SendNotification(message);
I am unable to alter the source code for the client application, so I would like to configure ServiceStack to use NotificationService for the client proxy, instead of SyncReply. Is there a way to do this?
UPDATE - It seems what I'm looking for is a way to configure ServiceStack so that it generates a different value for the name attribute of the wsdl:service tag; from SyncReply to NotificationServiceClient. I can save the current WSDL, manually manipulate it, and verify the proxy class name using a throw-away client.
Don't use ServiceStack's .NET Service Clients for consuming 3rd Party APIs, they're only designed and opinionated towards consuming ServiceStack Services.
The only HTTP Client we recommend for calling 3rd Party APIs is HTTP Utils which is a our general purpose HTML client.
Based on the comment by mythz, I have overridden the GenerateWsdl in my AppHost, and set the ServiceName property on the wsdlTemplate. Here's an example:
public override string GenerateWsdl(WsdlTemplateBase wsdlTemplate)
{
wsdlTemplate.ServiceName = "NotificationService";
return base.GenerateWsdl(wsdlTemplate);
}
I'm creating a .Net application to consume the Soap APIs.
I downloaded 2 partner wsdl files from 2 instances(production and sandbox). I think the only difference of the two APIs are their endpoints.
I then added the web references to a single application. When I write the method to consume the APIs, I don't want to duplicate the code to do same thing(insert,update...).
How can I design my code so maybe I can pass a parameter to let the method know which target instance should it talk to?
Thank you!
If the services are truly the same and just the endpoint differs, you should be able to use the generated client's Endpoint property to change the endpoint.
var client = new ServiceReference1.WebService1SoapClient();
client.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://localhost:2850/WebService1.asmx");
I am in the process of developing a WCF Service(WCFManager) which would send out request to other services and get response back. For this I developed a WCF service.
Trying to accomplish the following (Assuming that my service name is WCFManager)
What I did so far
Added a service reference of Service X to WCFManager which created a reference.cs and a WCF Client.
Using the WCF Client generated by adding service reference and sending the request to Service X by using the following code
WCFManagerClient client = new WCFManagerClient();
Response response = client.GetResponse(request);
What am I trying to accomplish
I want to add few config settings in a App.Config file of Service X, Service Y, Service Z which I did.
Reuse the same WCFManagerClient to send the request to Service Y or Service Z by reading the endpoint information from the config file. My assumption is that when I use the WCFManagerClient to send the request it uses the reference.cs created in the service reference of the WCFManager service.If my assumption is true can I change the reference.cs on the fly to include the Service Y binding information when I send the request to Service Y and same with the Service Z. This way I don't have to create a proxy for each Service.
Is it possible to reuse the same reference.cs file generated but include the binding information on the fly from config file.
3.I have no control over the Service Y or Service Z but all I know is services Endpoint information and the method names and the schema of each service would be the same.
I am not sure if this is possible in WCF if some one has gone through such design with WCF but any suggestions about my approach is apreciated.
I've been tasked with creating a class wrapper for a SOAP service, the idea is that you'll be able to treat it as a regular class. The main reason for this is that the WDSL for the SOAP service contains only one method and it's got 5 parameters and it's only kind of OO so you'd have to know all the method calls really well and it's a bit hard to remember them all.
OK, so I've tried adding a web reference, now web references can now be added as service references in VS 2010. You click add service reference advanced etc and it puts in a service reference. Great. Unfortunately if I try and access this from a class I can't.
I can build a console app and put code in the main procedure and access the method of the SOAP service fine but when I add a reference to a class library the intellisense won't allow me to select anything. I'd instantiate an instance like so:
SOAPService.webServiceService ws = new SOAPService.webserviceService();
ws.
and then the intellisense refuses to kick in. If I do the same in a web project or a console app then I can access it fine. I've added the namespace I've done all kinds of things. Also, I can add a web reference and get a DISCO file whenever I create a web project.
OK, also while I'm on the subject I also need to pass credentials to the web service in PHP.
The problem is that in the past I'd create some .net system credentials and add these and it would usually pass through if I was connecting to another .net service.
How should I be sending them to a PHP web service? I always get either invalid username/password combo errors or envelope malformatted error types
Thanks
Mr. B
So the intellisense is not working, but if you add the method in and try to use it does it work, or produce an error?
With regard to diagnosing authentication issues try using fiddler to view the SOAP messages that are being sent, and to view the reply. Do you have some other software that connects and authenticates to that service? Use fiddler to look at the SOAP messages and compare them to see if the header is different etc.
I'd normally do it like this,
using (Service service = new Service())
{
service.ClientCredentials.Windows.ClientCredential.Domain = "domain";
service.ClientCredentials.Windows.ClientCredential.Password = "password";
service.ClientCredentials.Windows.ClientCredential.UserName = "username";
}
Also with regard to the service working or not in general use fiddler if you have any problems, you can see the SOAP messages and it often gives you a clearer message.
I know in IIS you can turn on failed request handling that also gives you an insight from what is going on at the server end, perhaps you have some form of logging too for your php service?
What is the purpose of IMetadataExchange endpoint. Some places i found that if i dont define this endpoint, adding service reference will not work OR creating proxy using svcutil wont work. But both of this working without having IMetadataExchange defined.
If we have other endpoint with httpGetEnabled = true, we are able to create proxy from client.
Also, some article says that we should delete IMetadataExchange before moving code to production and it should development period only so that other client cant see metadata. Doesnt this stop the behaviour of service having self describing itself?
And if I have defined this IMetadataExchange endpoint, how can i see that on browser. Address whoch i have provided for this endpoint is not pulling any metadata in browser.
Service metadata can be served two ways:
Regular WSDL served over HTTP/HTTPS, which is what that http[s]GetEnabled=true enables.
WS-MetadataExchange (MEX) which uses SOAP (and not just a plain GET request over HTTP) and supports a few more advanced scenarios (in theory, at least). That's what the IMetadataExchange endpoint enables.