I have been provided a Web Service which i need to consume in my MVC application .
The user has provided
WSDL URL :
http://abc.xyz.nirp.com:50000/dir/wsdl?p=ic/310c503c873138a884ddd3ee4a5738e6
Binding Url:
http://abc123.ad.xyx.com:50000/XISOAPAdapter/MessageServlet?senderParty=&senderService=BS_HARMONY_D&receiverParty=&receiverService=&interface=ABC_OS&interfaceNamespace=http%3A%2F%2Fabc.com%2Fhcm%2Fabc
I am able to add a service reference using the WSDL URL using SOAP credential but i also need to add these in the web configs and app configs which i am not able to understand where to put .
Pointers on how to use this Binding Url and put it in Web Config and App Config which be really helpful for me.
Check your web.config. After adding a service reference visual studio adds the endpoint in your web.config. You probably have a section like that:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="DefaultServiceEndpoint">
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="ADDRESS_HERE"
binding="wsHttpBinding" bindingConfiguration="DefaultServiceEndpoint"
contract="ServiceReference1.SOME_CLASS" name="DefaultServiceEndpoint" />
</client>
</system.serviceModel>
You can change the address here.
i'm trying to connect a silverlight 4 application with an asmx webservice, but i'm getting an "InvalidOperationException" when trying to do so.
The problem occurs on the first line of this function
private void AskWebService() {
WSCalledSoapClient client = new WSCalledSoapClient();
client.AskThisCompleted += new EventHandler<AskThisCompletedEventArgs>(client_AskThisCompleted);
client.AskThisAsync("the answer to life, universe and everything");
}
The error of the exception should translate something like this (haven't found the english version of it)
element 'message' not recognized on the service reference configuration. Note that only a subset of the Windows Communication Foundation configuration functionality is available in Silverlight.
Details of the webservice:
Is published outside the silverlight project
Files clientaccesspolicy.xml and crossdomain.xml are in place
Details of the Silverlight App
SL version is 4.0, .net framework is also 4.0
Given the same config and same treatment (i.e. steps to import the webservice, code used to call the webservice), the call to the webservice works without problem on a new silverlight application that contains only a button and a textblock
The app uses others webservices, but only one is giving problem.
Update:
Here is the ServiceReferences.ClientConfig
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="WSCalledSoap" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://myip:someport/WSCalled.asmx"
binding="basicHttpBinding" bindingConfiguration="WSCalledSoap"
contract="SrvWSCalled.WSCalledSoap" name="WSCalledSoap" />
</client>
</system.serviceModel>
</configuration>
Any help will be appreciated.
Thanks.
I would like to consume 2 WCF web services located on 2 different hosts (the first accessible in HTTPS and the second one in HTTP). Both present the same methods, but the first one is on the production server, while the second one is on a test server.
When I add the references in my Visual Studio 2012 (express), I get 2 namespaces ; for now, the only way I found to consume these services is to use the interfaces and classes generated in these namespaces.
I would like to use only one web service, depending of a configuration item, indicating if I'm in debug or release mode.
How can I do that by code ?
Here is my config file :
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ILotWebContract">
<security mode="Transport" />
</binding>
<binding name="BasicHttpBinding_ILotWebContract1" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://xxx/Services/WebService/LotWebService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ILotWebContract"
contract="eMol.ILotWebContract" name="BasicHttpBinding_ILotWebContract" />
<endpoint address="http://yyy/Services/WebService/LotWebService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ILotWebContract1"
contract="eMolTest.ILotWebContract" name="BasicHttpBinding_ILotWebContract1" />
</client>
</system.serviceModel>
I tried to change the endpoint's address :
eMolTest.LotWebContractClient client = new eMolTest.LotWebContractClient();
client.Endpoint.Address = new System.ServiceModel.EndpointAddress("https://xxx/Services/WebService/LotWebService.svc");
client.Endpoint.Binding = new System.ServiceModel.WSHttpBinding(System.ServiceModel.SecurityMode.Transport);
but the exception generated while running the client indicate that the links between client and service probably do not correspond.
I also tried to indicate the name of the endpoint when I call the proxy's contructor :
eMolTest.LotWebContractClient client = new eMolTest.LotWebContractClient("BasicHttpBinding_ILotWebContract");
but again it does not work because of the namespaces which are different (the contract's name contains the namespace's name, and can therefore not be found in the endpoint as defined in the config file).
So, if someone has a good idea ...
Thanks !
Chris
If you have two services with the exact same contract, you should share it's contract as a contract assembly between all three parties and use a ChannelFactory class to create the proxy yourself. That way you don't have two service references that although they represent the same contract are incompatible from a compiler perspective.
How to configure XML web services client to use MessageVersion.Soap11WSAddressing10 for header namespaces. Currently it uses MessageVersion.None namespace, without me able to change it.
You need to do this using a custom WCF binding:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="Soap11Addr10">
<textMessageEncoding messageVersion="Soap11WSAddressing10" />
<httpTransport/>
</binding>
</customBinding>
</bindings>
and then reference that custom binding (by name) in your service endpoint:
<services>
<service name="YourAssembly.YourService">
<endpoint name="test"
address=""
binding="customBinding"
bindingConfiguration="Soap11Addr10"
contract="YourAssembly.IYourService" />
</service>
</services>
</system.serviceModel>
If you want to use this from a client, you also need to copy the custom binding configuration to the client's app.config or web.config and reference it there, of course (using Add Service Reference in Visual Studio will do this for you).
Any ideas how to fix this?
UserService.UserServiceClient userServiceClient = new UserServiceClient();
userServiceClient.GetUsersCompleted += new EventHandler<GetUsersCompletedEventArgs>(userServiceClient_GetUsersCompleted);
userServiceClient.GetUsersAsync(searchString);
.
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_UserService"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:52185/UserService.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_UserService"
contract="UserService.UserService"
name="BasicHttpBinding_UserService" />
</client>
<behaviors>
<serviceBehaviors>
<behavior name="Shell.Silverlight.Web.Service3Behavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<services>
<service behaviorConfiguration="Shell.Silverlight.Web.Service3Behavior"
name="Shell.Silverlight.Web.Service3">
<endpoint address=""
binding="basicHttpBinding"
contract="Shell.Silverlight.Web.Service3" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
Could not find default endpoint element that references contract 'UserService.UserService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
Resolved!
I didn't mention that this was a Silverlight application. I had the wcf reference in a DLL which had it's own "ServiceReferences.ClientConfig" file. I moved the contents of the DLL's ServiceReferences.ClientConfig to the main silverlight project and it worked.
I had a run in with the same problem. My application was also a Silverlight application and the service was being called from a class library with a custom UserControl that was being used in it.
The solution is simple. Copy the endpoint definitions from the config file (e.g. ServiceReferences.ClientConfig) of the class library to the config file of the silverlight application. I know you'd expect it to work without having to do this, but apparently someone in Redmond had a vacation that day.
You can also set these values programatically in the class library, this will avoid unnecessary movement of the config files across the library.
The example code for simple BasciHttpBinding is -
BasicHttpBinding basicHttpbinding = new BasicHttpBinding(BasicHttpSecurityMode.None);
basicHttpbinding.Name = "BasicHttpBinding_YourName";
basicHttpbinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
basicHttpbinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
EndpointAddress endpointAddress = new EndpointAddress("http://<Your machine>/Service1/Service1.svc");
Service1Client proxyClient = new Service1Client(basicHttpbinding,endpointAddress);
Just in case anyone hits the same problem whilst using WPF (rather than WCF or Silverlight):
I had this error, when connecting to a Web Service. When my code was in the "main" WPF Application solution, no problem, it worked perfectly. But when I moved the code to the more sensible DAL-layer solution, it would throw the exception.
Could not find default endpoint element that references contract 'MyWebService.MyServiceSoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
As has been stated by "Sprite" in this thread, you need to manually copy the tag.
For WPF apps, this means copying the tag from the app.config in my DAL solution to the app.config in the main WPF Application solution.
I ran into the same issue, for whatever reason Visual Studio did not update the web config when I first added the service. I found that updating the Service Reference also fixed this issue.
Steps:
Navigate to the Service Reference Folder
Expand it
Right Click and Select update Service Reference
Observe web Config be updated
Change the web.config of WCF service as "endpoint address="" binding="basicHttpBinding"..." (previously binding="wsHttpBinding")After build the app, in "ServiceReferences.ClientConfig" ""configuration> has the value. Then it will work fine.
Rename the output.config produced by svcutil.exe to app.config.
it worked for me.
Do you have an Interface that your "UserService" class implements.
Your endpoints should specify an interface for the contract attribute:
contract="UserService.IUserService"
Not sure if this is an issue.
Endpoint and binding both have the same name
Not sure if it's really a problem, but I see you have the same name for your binding configuration ().
I usually try to call my endpoints something like "UserServiceBasicHttp" or something similar (the "Binding" really doesn't have anything to do here), and I try to call my binding configurations something with "....Configuration", e.g. "UserServiceDefaultBinding", to avoid any potential name clashes.
Marc
Had to add the service in the calling App.config file to have it work. Make sure that you but it after all . This seemed to work for me.
This problem occures when you use your service via other application.If application has config file just add your service config information to this file.
In my situation there wasn't any config file so I use this technique and it worked fine.Just store url address in application,read it and using BasicHttpBinding() method send it to service application as parameter.This is simple demonstration how I did it:
Configuration config = new Configuration(dataRowSet[0]["ServiceUrl"].ToString());
var remoteAddress = new System.ServiceModel.EndpointAddress(config.Url);
SimpleService.PayPointSoapClient client =
new SimpleService.PayPointSoapClient(new System.ServiceModel.BasicHttpBinding(),
remoteAddress);
SimpleService.AccountcredResponse response = client.AccountCred(request);
For those who work with AX 2012 AIF services and try to call there C# or VB project inside AX (x++) and suffer from such errors of "could not find default endpoint"... or "no contract found" ...
go back to your visual studio (c#) project and add these lines before defining your service client, then deploy the project and restart AX client and retry:
Note, the example is for NetTcp adapter, you could easily use any other adapter instead according to your need.
Uri Address = new Uri("net.tcp://your-server:Port>/DynamicsAx/Services/your-port-name");
NetTcpBinding Binding = new NetTcpBinding();
EndpointAddress EndPointAddr = new EndpointAddress(Address);
SalesOrderServiceClient Client = new SalesOrderServiceClient(Binding, EndPointAddr);
In case if you are using WPF application using PRISM framework then configuration should exist in your start up project (i.e. in the project where your bootstrapper resides.)
In short just remove it from the class library and put into a start up project.