I have a method like this:
var stringReader = new StringReader(ruleSetXmlDefinition);
var reader = XmlReader.Create(stringReader);
var serializer = new WorkflowMarkupSerializer();
return serializer.Deserialize(reader) as RuleSet;
When the ruleSetXmlDefinition is greater than 32768 characters long I get the following error:
Unexpected end of file while parsing Name has occurred. Line 1,
position 32768.
How can I change this so that it can handle strings of any length?
I suspect you can configure Wcf to accept bigger arrays, see also this answer:
Maximum array length quota
Something like
<netTcpBinding>
<binding name="NetTcpBinding_ImageResizerServiceContract" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
I have found the answer to this issue and unfortunately it was something really obvious...the string I was passing in was actually being truncated so the issue was actually that the xml was not well formed.
Related
In the below code i place appconfig when i upload large file it throws no endpoint listening.If the file size is small it works fine.Pls help me to rectify the issue.
<binding name="BasicHttpBinding_IFileTransfer" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
textEncoding="utf-8" useDefaultWebProxy="true" messageEncoding="Text">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
I have two environments running the same WCF web service but one of them seems to have a 3-5 minute delay returning the XML data. The slow down seems to occur in relation to the size of the data being returned. The web service just retrieves an XML string from a database so the processing time is constant.
The endpoint bindings are the same for both but I'm wondering what else would cause a delay.
I ran a trace and it shows that the TransportReceive happens at the same time on both environments, but on the delayed environment the ServiceLevelReceiveReply occurs after 3-5 minutes.
Any idea what could cause this? I'm happy to provide as much data as possible.
Here are the two bindings that are used. MyPolicySoap is used for getting the XML.
<basicHttpBinding>
<binding name="MyPolicySoap" closeTimeout="00:11:00" openTimeout="00:11:00" receiveTimeout="00:10:00" sendTimeout="00:11:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="5000000" maxBufferPoolSize="524288" maxReceivedMessageSize="5000000" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="5000000" maxArrayLength="16384" maxBytesPerRead="5000000" maxNameTableCharCount="16384"/>
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="MyConfig" maxReceivedMessageSize="2147483647">
<readerQuotas maxStringContentLength="2147483647"/>
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm=""><!--<extendedProtectionPolicy policyEnforcement="Never" />--></transport>
<message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true"/>
</security>
</binding>
</wshttpbinding>
When switching from no security to Certificate I get a WindowsIdentity in the IAuthorizationPolicy.Evaluate (evaluationContext.Properties.TryGetValue("Identities", out obj)? Is this by design :
From this :
<binding name="NetTcpBinding_IMyAppClientServiceRegular" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="infinite" sendTimeout="01:00:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<reliableSession ordered="true" inactivityTimeout="infinite" enabled="false"/>
<security mode="None">
<transport clientCredentialType="None"/>
</security>
</binding>
To this :
<binding name="netTcpCertificate" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="infinite" sendTimeout="01:00:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="1000" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="200" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<reliableSession ordered="true" inactivityTimeout="infinite" enabled="false"/>
<security>
<message clientCredentialType="Certificate"/>
</security>
</binding>
Is there any way to avoid getting the WindowsIdentity in IAuthorizationPolicy.Evaluate? I do only want the WindowsIdentity to be set when using this binding :
<binding name="NetTcpBinding_IMyAppClientServiceWindows" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="infinite" sendTimeout="01:00:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<reliableSession ordered="true" inactivityTimeout="infinite" enabled="false"/>
<security mode="Message">
<message clientCredentialType="Windows"/>
</security>
I noticed you have not set the mode in <security> in your netTcpCertificate config instead of what you probably want: <security mode="Message">. By not setting the mode attribute, WCF will use the default value of Transport instead of Message which is what you likely want for certificate credentials. It's possible that WCF is passing the Windows identity when the mode is set to transport but I haven't tried to verify it.
UPDATE:
Based on the comments below, you should make sure that the client config file endpoint>indentity>dns>value matches the name of server certificate CN= value. This value needs to be MyAppServer based on what you entered.
i want to use the below Web-Service :
https://acquirer.sb24.com/ref-payment/ws/ReferencePayment?WSDL
and builded config file after adding ->
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="PaymentIFBinding" 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="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="PaymentIFBinding1" 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="https://acquirer.sb24.com:443/ref-payment/ws/ReferencePayment"
binding="basicHttpBinding" bindingConfiguration="PaymentIFBinding"
contract="SB24Service.PaymentIF" name="PaymentIFPort" />
</client>
</system.serviceModel>
</configuration>
i want to call verifyTransaction method of this WebService :
PaymentIFClient pic = new PaymentIFClient();
double pic_result = pic.verifyTransaction(str1, str2);
but the first line throws the below error :
Could not find default endpoint element that references contract
'SB24Service.PaymentIF' 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.
EDIT :
"This error can arise if you are calling the service in a class
library and calling the class library from another project." -> My
Situation is like this ...
what should i change i configuration file ?
thanks in advance
Editing wcf configuration by hand is tricky, as there are many sections that need to be correct and correctly reference each other. Try opening your app.config file in SvcConfigEditor (also available from the Tools menu in Viusal Studio). It is way easier to get things correct when having GUI help on what to do.
I'm trying to send a long string by WCF, around 64k chars long. When sending a long string, the I get the HTTP error 400. But when I send shorter string, everything works fine.
Here is the WCF interface and app.config that I use.
My message contract:
[MessageContract]
public class MessageClass
{
[MessageHeader(MustUnderstand = true)]
public string id;
[MessageBodyMember(Order=1)]
public string realMessage; // Long string
}
I have tried to change the app.config settings by rising the values:
<bindings>
<basicHttpBinding>
<binding
name="ws"
transferMode="Streamed"
messageEncoding="Mtom"
maxReceivedMessageSize="10067108864">
<readerQuotas
maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
Is there any other value that I should change?
You also need to set the "maxBufferSize" and "maxBufferPoolSize" on your binding:
<bindings>
<basicHttpBinding>
<binding
name="ws"
transferMode="Streamed"
messageEncoding="Mtom"
maxReceivedMessageSize="10067108864"
maxBufferSize="500000" maxBufferPoolSize="500000">
<readerQuotas
maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
Those also default to 64K in WCF's standard bindings. However, since you're using the "transferMode=Streamed", this really shouldn't be an issue - maybe there's something else going on. How about also increasing the sendTimeout setting? Maybe your service is just taking a tad too long to respond.
Marc
See the maxReceivedMessageSize attribute of the basicHttpBinding # http://msdn.microsoft.com/en-us/library/ms731361.aspx. Coindicentally, the default is 65,536 KB.