I'm working on a project which includes a file uploader, now after extensive research and experimentation the uploader is working. However, it makes me uneasy as I don't understand the part that got it working the way I wanted it to. In order to achieve my goal I had to add a binding element to the service and the client (n-tier application) I don't really understand the binding element to tell you the truth, but I really don't understand the parameters in this element. If anyone is able, please provide a source where I can read up on these specific elements and if possible, describe them yourself.
Here is the section of code:
<binding name="BasicHttpBinding_IFileUploadService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="8388608"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas
maxDepth="32" maxStringContentLength="8192"
maxArrayLength="8388608" maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
</binding>
Found exactly what I was looking for after wording my google search appropriately
http://msdn.microsoft.com/en-us/library/System.ServiceModel.BasicHttpBinding_properties(v=vs.85).aspx
Related
Hi i'm create a code generation tool for Odata, so far the odata v4 have been really simple to implement.
Regarding odata V3 i have been having troubles with the metadata because I don't know where actions are defined so far I have been only able to see FunctionImport on metadata but not actions, are FunctionImport an equivalent to actions for OData V3? if not can you point on which node of the metadata are the actions located ?
thanks
Actions can be bound or unbound and can be added to the metadata(EDM) as follows:
builder.Entity<entityname>.Action("actionname").Parameter<type>("paramtername").Returns<type>();
Here, builder can be either ODataBuilder or ConventionalOdataBuilder.
If you want the action to be unbound, you can remove the Entity and directly add it to the builder.
If you wish to add the action to IEdmModel directly, you can add the action as a schemaelement.
Source:https://learn.microsoft.com/en-us/aspnet/web-api/overview/odata-support-in-aspnet-web-api/odata-v3/odata-actions
Edit: Actions are defined in metadata as follows:
<Schema Namespace="Default" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
<EntityContainer Name="Container" m:IsDefaultEntityContainer="true">
<EntitySet Name="Movies" EntityType="ODataActionsSample.Models.Movie" />
<FunctionImport Name="SetDueDate" ReturnType="ODataActionsSample.Models.Movie" IsBindable="true" EntitySet="Movies" m:IsAlwaysBindable="true">
<Parameter Name="bindingParameter" Type="ODataActionsSample.Models.Movie" />
<Parameter Name="DueDate" Type="Edm.DateTime" Nullable="false" />
</FunctionImport>
<FunctionImport Name="CreateMovie" ReturnType="ODataActionsSample.Models.Movie" EntitySet="Movies">
<Parameter Name="Title" Type="Edm.String" FixedLength="false" Unicode="false" />
</FunctionImport>
</EntityContainer>
we need to define a different file url via simple naming bindings for every server in a JBoss domain.
e.g. we need for every server in the cluster an entry like
<subsystem xmlns="urn:jboss:domain:naming:1.4">
<bindings>
<simple name="java:/url/ServerConfigurationUrl" value="file:///c:/JBoss//server3.properties" type="java.net.URL"/>
</bindings>
</subsystem>
Can this be achieved using some variables? Expressions seem not to be valid here.
If we could just use something like value=${path to file} that would be great.
Thanks,
ralf
Using something like
<system-properties>
<property name="FILEURL" value=value="file:///c:/JBoss//server3.properties" />
</system-properties>
and then
<bindings>
<simple name="java:/url/ServerConfigurationUrl" value="${FILEURL}" type="java.net.URL"/>
</bindings>
worked for me.
Greetings,
ralf
I got 1 Azure web role for multiple websites, and it worked, the code in "ServiceDefinition.csdef" looks like:
<Sites>
<Site name="SiteA" physicalDirectory="..\SiteA">
<Bindings>
<Binding name="HttpBinding" endpointName="HttpEndpoint" hostHeader="a.com" />
</Bindings>
</Site>
<Site name="SiteB" physicalDirectory="..\SiteB">
<Bindings>
<Binding name="HttpBinding" endpointName="HttpEndpoint" hostHeader="b.com" />
</Bindings>
</Site>
<Site name="SiteC" physicalDirectory="..\SiteC">
<Bindings>
<Binding name="HttpBinding" endpointName="HttpEndpoint" hostHeader="c.com" />
</Bindings>
</Site>
</Sites>
A, B, C all works.
but the situation is, A, B, C are projects, need to build ( as release ) to get them work well.
What Azure tool (in Visual Studio) does is just simply copy them (the folder) not build them ( as release). The result is, all files on server, even MVC patten works, but the Web.Release.config does not replace(a part of) Web.config, so some codes not work.
My question is, how to setup Azure support multiple projects, and build them as release, in one web role?
This might be a pretty basic issue but I feel like I'm way over my head with it. I created a client side web service java object using the customer provided wdsl (wsimport). the problem is that they are saying I need to include a security header so it will connect. the header is not in the WSDL. I did some research into this and it seems that I need to import a wsit-client.xml into it when I do the wsimport. I can't seem to find a clear example of this file. I have tried to piece one together from the example I have found but when I run wsimport it never seems to pick it up. here is what I have:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions targetNamespace="http://www.jboss.org/jbossws/ws-extensions/wssecurity" name="SecurityService"
xmlns:tns="http://www.jboss.org/jbossws/ws-extensions/wssecurity"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:wspp="http://java.sun.com/xml/ns/wsit/policy"
xmlns:sc="http://schemas.sun.com/2006/03/wss/server"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<portType name="LOOKUP_PortType"/>
<binding name="LOOKUP_Binding" type="tns:LOOKUP_PortType">
<wsp:PolicyReference URI="#lookupSecurityPolicy"/>
</binding>
<service name="XXSW_GPOS_CUSTOMER_CREDIT_PKG_Service">
<port name="XXSW_GPOS_CUSTOMER_CREDIT_PKG_Port" binding="tns:LOOKUP_Binding"/>
</service>
<wsp:Policy wsu:Id="lookupSecurityPolicy">
<wsp:ExactlyOne>
<wsp:All>
<sc:CallbackHandlerConfiguration wspp:visibility="private">
<sc:CallbackHandler name="usernameHandler" default="username" />
<sc:CallbackHandler name="passwordHandler" default="password" />
</sc:CallbackHandlerConfiguration>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</definitions>
the XML isn't malformed but I know I'm missing something or completely have the whole idea of this wrong. I really need a good walk through of how to create this but I can't seem to find one on the net. any help would be very appreciated.
wsit-client.xml is not used by wsimport. You put in in /META-INF/ and Metro reads it when you connect to the service.
I am super new to MVC (in fact, this is my first assignment)
So, I have a good webservice running, functional, on my local machine
http://www.codetrials.local/wcf/UserServices.svc?wsdl
and In my MVC application, I added a service reference as usual, and then in my Model.cs I am trying this:
using (CodeTrials.UserServicesClient _client = new UserServicesClient())
{
UserWebsite = _client.GetUserWebsite(username);
}
but when I try to run this, I always get the exception endpoint not found. I can access this from my (different) asp.net project and it works just fine, same code and everything. After some digging around I found this answer I modified my above code to:
BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress address = new EndpointAddress("http://www.codetrials.local/wcf/UserServices.svc");
using (CodeTrials.UserServicesClient _client = new UserServicesClient(binding, address))
{
UserWebsite = _client.GetUserWebsite(username);
}
but now, I get a new exception: There was no endpoint listening at http://www.codetrials.local/wcf/UserServices.svc?wsdl that could accept the message
So I am at my wits end.
I found a similar question but it's not what I am looking for.
Can you please guide me to the right path?
what am I not doing right?
should I shift the consuming of webservice from Model to Controller?
Thanks.
EDIT - This is my config file system.serviceModel section. I just copy pasted it from the WCF client test gui tool into web.config since it was not being generated by visual studio.
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IUserServices" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://www.codetrials.local/wcf/UserServices.svc/wcf/UserServices.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IUserServices"
contract="IUserServices" name="BasicHttpBinding_IUserServices" />
</client>
</system.serviceModel>
Reposting from the comments since it turned out to be the answer. :) Turned out that web.debug.config was overwriting the web.config in this case.
Are you sure its in the right web.config then? VS should create it automatically when you add the service reference (it does for me at least). One gotcha is that a normal MVC app has two web.config files, there's a second one inside the Views folder by default. Other then that, I'm not really sure whats going on.
Your code shows you are using this URL: http://www.codetrials.local/wcf/UserServices.svc to access the service endpoint but your exception message says you are actually using http://www.codetrials.local/wcf/UserServices.svc?wsdl instead.
Check your MVC app web.config file for a serviceModel element. If you need to configure the WCF client in code then remove that entire element from the web.config file which may be where the wrong URL is coming from. If you do want to configure WCF from the web.config file, then remove your current code and use the following two lines to create the client and invoke the service:
var _client = new UserServicesClient("BasicHttpBinding_IUserServices");
UserWebsite = _client.GetUserWebsite(username);
where the something like the following section exists in your web.config serviceModel element:
<system.serviceModel>
<client>
<endpoint
name="BasicHttpBinding_IUserServices"
address="http://www.codetrials.local/wcf/UserServices.svc"
binding="basicHttpBinding"
contract="IUserServices" >
</endpoint>
</client>
<!-- rest of element snipped -->
Finally, you should not wrap the UserServicesClient instantiation in a using statement because of the reasons outlined in this post. WCF is a tricksty beast....
EDIT:
Based on the update with your config, your problem may be that the service URL is:
http://www.codetrials.local/wcf/UserServices.svc/wcf/UserServices.svc
The wcf/UserServices.svc seems to be duplicated.