I have hosted one WCF Service on the Azure platform and in web.config enabled basic authentication as per below
<system.serviceModel>
<services>
<service behaviorConfiguration="SimpleServiceBehavior" name="RestService.RestServiceImpl">
<endpoint address="http://localhost/RestWCFDemo/RestServiceImpl.svc" binding="webHttpBinding" bindingConfiguration="secureBasic" contract="RestService.IRestServiceImpl" behaviorConfiguration="HttpEnableBehavior" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="secureBasic">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic"></transport>
</security>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="HttpEnableBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="SimpleServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
On Azure it is not running. In local I have hosted this service on IIS and Enabled basic authentication only then it will ask for credentials when I will access it from URL, same way I have disabled all authentication methods except basic still I can't run this service what could be the problem? Can anyone suggest a solution?
You can try adding a a proxyCredentialType to your transport:
<transport clientCredentialType="Basic" proxyCredentialType="Basic"/>
I would also set includeExceptionDetailInFaults="true" so you can see the problem better if that doesn't work.
Related
Have two clients to use the service the two protocls
<system.serviceModel>
<services>
<Service name ="ServcieName">
<endpoint address ="" binding="basicHttpBinding" contract="ContractName">
</endpoint>
<endpoint address ="" binding="netTcpBinding" contract="ContractName">
</endpoint>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
I want a responses from both the end points.
The namespace system.serviceModel need to be used in the project, as this converts the interface into a service model.
Config file:
In the configuration file for communicating with the Service need to use the Mex behaviour as a service Behaviour
<serviceMetadata httpGetEnabled="true"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
And for 2 different bindings, need to use
<endpoint address="SampleService" binding="basicHttpBinding" contract="SampleService.ISampleService"/>
<endpoint address="SampleService" binding="netTcpBinding" contract="SampleService.ISampleService"/>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="SampleService.SampleService" behaviorConfiguration="mexBehaviour">
<endpoint address="SampleService" binding="basicHttpBinding" contract="SampleService.ISampleService"/>
<endpoint address="SampleService" binding="netTcpBinding" contract="SampleService.ISampleService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://loclahost:8080"/>
<add baseAddress="net.tcp://loclahost:8090"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehaviour">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Sample service code
public class SampleService : ISampleService
{
public string GetMessage(string name)
{
return " Hello " + name;
}
}
I developed a wcf webservice in a sharepoint 2016 on premise environment.
When I try to upload a long body I used to get a 413 payload too large error so I changed my app.config to this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="ilem.Sharepoint.WebServices.ISAPI.ilemGroupWS.Service">
<endpoint address="" binding="basicHttpBinding" contract="ilem.Sharepoint.WebServices.ISAPI.ilemGroupmWS.IService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/ilem.Sharepoint.WebServices.ISAPI.ilemGroup/Service/" />
</baseAddresses>
</host>
</service>
</services>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name=""
helpEnabled="true"
automaticFormatSelectionEnabled="true"
maxReceivedMessageSize="2147000000"
/>
</webHttpEndpoint>
</standardEndpoints>
<bindings>
<basicHttpBinding>
<binding name="MyBinding" maxBufferPoolSize="2000000000"
maxBufferSize="2000000000" maxReceivedMessageSize="2000000000">
<readerQuotas maxDepth="32"
maxArrayLength="200000000"
maxStringContentLength="200000000"/>
</binding>
</basicHttpBinding>
<basicHttpsBinding>
<binding name="MyBinding" maxBufferPoolSize="2000000000"
maxBufferSize="2000000000" maxReceivedMessageSize="2000000000">
<readerQuotas maxDepth="32"
maxArrayLength="200000000"
maxStringContentLength="200000000"/>
</binding>
</basicHttpsBinding>
</bindings>
</system.serviceModel>
</configuration>
But now I get this error: 500 (System.ServiceModel.ServiceActivationException)
Is there any way to resolve this issue?
I found that behaviorConfiguration, bindingConfiguration, <security mode="Transport"> are not set in your code, please make sure to configure them.
You can try setting includeExceptionDetailInFaults to true or configuring tracing to get error details.
I am able to implement a connected service in a console app via the service reference option in VS using a wsdl. The following configuration changes are required in the app.config for the service to work:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="......">
<security enableUnsecuredResponse="true" authenticationMode="MutualCertificate" allowSerializedSigningTokenOnReply="true" includeTimestamp="false" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" requireSignatureConfirmation="false">
<localClientSettings maxClockSkew="00:10:00" detectReplays="false" />
<localServiceSettings maxClockSkew="00:10:00" detectReplays="false" />
<secureConversationBootstrap>
<localClientSettings detectReplays="false" />
<localServiceSettings detectReplays="false" />
</secureConversationBootstrap>
<issuedTokenParameters useStrTransform="true"></issuedTokenParameters>
</security>
<textMessageEncoding messageVersion="Soap11" />
<httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" requireClientCertificate="true">
</httpsTransport>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="...." binding="...." behaviorConfiguration="....." bindingConfiguration="....." contract="...." name="...." />
</client>
<behaviors>
<endpointBehaviors>
<behavior name="....">
<clientCredentials>
<serviceCertificate>
<defaultCertificate storeLocation="..." storeName="..." findValue="...." x509FindType="FindBySerialNumber" />
<authentication certificateValidationMode="None" revocationMode="NoCheck" />
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
When I using the same wsdl to setup a connected service in an Azure Function via WCF Web Service Reference the result does not an app.config. How do I implement the app.config above in the Azure Function connected service?
You can use the svcutil tool to generate proxy classes and config files and add them to your project to implement calls.
I have an old WCF webservice that's been moved to Azure VM.
I can easily access in Azure:
https://wcf/service.svc,
but when I try to post to:
https://wcf/service.svc/json/DoAction
it comes back with an empty response, when I open this in the browser I get 404 error.
Outside of Azure it all works fine, any ideas what can I do to get it to work? I would like to keep it running in VM as there are other items that were moved and work fine.
Here is the part of the web.config file that relates to "/json/" part:
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="Service123" behaviorConfiguration="ChallengeBehavior">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="ChallengeMessageEncoding" contract="IService123" behaviorConfiguration="SoapServiceBehavior" />
<endpoint address="/json" binding="webHttpBinding" bindingConfiguration="RestServiceMessageEncoding" contract="IService123" behaviorConfiguration="RestServiceBehavior" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="RestServiceBehavior">
<webHttp defaultOutgoingResponseFormat="Json" automaticFormatSelectionEnabled="true" />
</behavior>
<behavior name="SoapServiceBehavior">
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="RestServiceMessageEncoding">
<security mode="None">
</security>
</binding>
</webHttpBinding>
<wsHttpBinding>
<binding name="ChallengeMessageEncoding">
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" />
<message clientCredentialType="None" establishSecurityContext="false" negotiateServiceCredential="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
There is no problem the code snippets seem to me. Which version IIS is installed in the Azure VM? Do you have enabled the feature supported for WCF in IIS.
I suspect that the WCF service published on the VM does not work properly. Try to publish a default WCF service application project and browse the self-introduction page.
In addition, for a specific port, you need to enable outbound/inbound permission on the firewall.
VM>>Settings>>Network
Feel free to contact me if there is anything I can help with.
#Abraham, thank you for your answer.
I finally got it working, not sure which part helped but changes I introduced included:
a) Installed additional WCF features (as above) as only 2 were installed
b) Added extra bits to web config (allowing to run URLs with dots in name /Foo.svc/Save )
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
<clear />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="/*" verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
c) Another config to support dots:
<modules runAllManagedModulesForAllRequests="true" />
d) Extended endpoints to support HTTPS as the above started working for HTTP:
<service name="PrivateService" behaviorConfiguration="PrivateBehavior">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="PrivateBehavior" contract="IPrivateService" behaviorConfiguration="SoapBehavior" />
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="PrivateBehaviorSecure" contract="IPrivateService" behaviorConfiguration="SoapBehavior" />
<endpoint address="/json" binding="webHttpBinding" bindingConfiguration="RestSecure" contract="IPrivateServices" behaviorConfiguration="RestBehavior" />
<endpoint address="/json" binding="webHttpBinding" bindingConfiguration="Rest" contract="IPrivateService" behaviorConfiguration="RestBehavior" />
</service>
...
<webHttpBinding>
<binding name="Rest">
<security mode="None">
</security>
</binding>
<binding name="RestSecure">
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" />
</security>
</binding>
</webHttpBinding>
Does a WCF service on SharePoint require that Anonymous Access is enabled?
We have an application page which is calling the service using Ajax.Net, if Anon Access is off then we get prompted for the username and password, if it is on then all is well.
We are not using a WCF client, it is purely being called by the scriptmanager
<configuration>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding
name="webHttpBinding_DataSources"
maxBufferSize="5242880"
maxReceivedMessageSize="5242880" />
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior
name="ServiceAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior
name="ServiceBehavior">
<serviceMetadata
httpGetEnabled="true"
httpGetUrl="" />
<serviceDebug
includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment
aspNetCompatibilityEnabled="true"/>
<services>
<service
name="XXXXXXXX.DataSources.Services.DataSourceHelper"
behaviorConfiguration="ServiceBehavior">
<endpoint
address=""
behaviorConfiguration="ServiceAspNetAjaxBehavior"
binding="webHttpBinding"
bindingConfiguration="webHttpBinding_DataSources"
contract="XXXXXXXX.DataSources.Services.IDataSourceHelper" />
</service>
</services>
</system.serviceModel>
</configuration>
Thanks, Phill
I managed to get it working with the following
<configuration>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding
name="webHttpBinding_DataSources"
maxBufferSize="5242880"
maxReceivedMessageSize="5242880" >
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" />
</security>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior
name="ServiceAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior
name="ServiceBehavior">
<serviceMetadata
httpGetEnabled="true"
httpGetUrl="" />
<serviceDebug
includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment
aspNetCompatibilityEnabled="true"/>
<services>
<service
name="XXXXXXXXXX.DataSources.Services.DataSourceHelper"
behaviorConfiguration="ServiceBehavior">
<endpoint
address=""
behaviorConfiguration="ServiceAspNetAjaxBehavior"
binding="webHttpBinding"
bindingConfiguration="webHttpBinding_DataSources"
contract="XXXXXXXXXX.DataSources.Services.IDataSourceHelper" />
</service>
</services>
</system.serviceModel>
</configuration>
I did an IISReset and had to close and re-open my browser to get it working though
Best Regards,
Phill