I have a WCF service that is hosted on localhost. This WCF service runs in the background to support another C# application that accesses that service. The communication works when the background is accessed locally from my local machine.
But when I try to containerize the entire setup of the background service and C# application, It starts throwing an error inside the WCF service i.e the proxy class.
I am getting the following eror:
Communication Exception on GetDCP, Ex: Server stack trace: at
System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message
reply, MessageFault fault, String action, MessageVersion version,
FaultConverter faultConverter) at
System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime
operation, ProxyRpc& rpc) at
System.ServiceModel.Channels.ServiceChannel.Call(String action,
Boolean oneway, ProxyOperationRuntime operation, Object[] ins,
Object[] outs, TimeSpan timeout) at
System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage
methodCall, ProxyOperationRuntime operation) at
System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage
message) Exception rethrown at [0]: at
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg) at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type) at DPCS.GetDCP(String toolName) at
DPCSFormClient.MainForm.StartSessionAndGetDCP(Object entity,
DPCSClient& clientBatch, List`1& svidNameList) in
C:\tfs\E3\DPCS\DPCSFormClient\MainForm.cs:line 184
This is how my config file looks like:
<system.serviceModel>
<bindings>
<netNamedPipeBinding>
<binding name="NetNamedPipeBinding_DPCS" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="24.20:31:23.6470000" sendTimeout="00:05:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxBufferSize="1310700" maxConnections="10" maxReceivedMessageSize="1310700">
<readerQuotas maxDepth="32" maxStringContentLength="1310700" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None">
<transport protectionLevel="None"/>
</security>
</binding>
</netNamedPipeBinding>
</bindings>
<client>
<endpoint address="net.pipe://localhost/Intel/E3/DPCSService" binding="netNamedPipeBinding" bindingConfiguration="NetNamedPipeBinding_DPCS" contract="DPCS" name="NetNamedPipeBinding_DPCS">
</endpoint>
</client>
</system.serviceModel>
And this is how my proxy class looks like:
public interface ABCD
{
[System.ServiceModel.OperationContractAttribute(Action="http://prox.A.ABCD/XYZ/StartSession", ReplyAction="http://prox.A.ABCD/XYZ/StartSessionResponse")]
[System.ServiceModel.FaultContractAttribute(typeof(prox.A.ABCD.E3Fault), Action="http://prox.A.ABCD/Fault", Name="Fault", Namespace="http://schemas.datacontract.org/2004/07/prox.A.ABCD")]
void StartSession(string sessionXML);
[System.ServiceModel.OperationContractAttribute(IsInitiating=false, Action="prox.A.ABCD/XYZ/GetCon", ReplyAction="prox.A.ABCD/XYZ/DPCS/GetConResponse")]
[System.ServiceModel.FaultContractAttribute(typeof(prox.A.ABCD.Fault), Action="http://prox.A.ABCD/Fault", Name="Fault", Namespace="http://schemas.datacontract.org/2004/07/prox.A.ABCD")]
string GetCon(string toolName);
only adding some part of code
Related
I've tried to execute a method of a web service on my console application (c# .Net 4.5.2), but I've received the following error: "(415) Cannot process the message because the content type 'application/xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'.."
app.config
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="AnotherBindingWS"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647" />
</webHttpBinding>
<basicHttpBinding>
<binding name="BasicHttpBinding_IIntegracion"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"/>
</basicHttpBinding>
</bindings>
<client>
<endpoint
name="BasicHttpBinding_IIntegracion"
address="http://servicios.cruzdelsur.com/Interfaces_Test/Integracion.svc"
binding="webHttpBinding"
bindingConfiguration="AnotherBindingWS"
contract="WSIntegracionCDS.IIntegracion"
behaviorConfiguration="webhttp"/>
</client>
<services>
<service name="WSIntegracionCDS.IIntegracion">
<endpoint
name="AnotherBindingServiceWS"
address="http://servicios.cruzdelsur.com/Interfaces_Test/Integracion.svc"
binding="webHttpBinding"
bindingConfiguration="AnotherBindingWS"
contract="WSIntegracionCDS.IIntegracion"
behaviorConfiguration="webhttp"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webhttp">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
Program.cs
IntegracionClient clientWS = new IntegracionClient();
CrearDespachos_Input inputDespachosWS = new CrearDespachos_Input();
List<Despacho> newDespachos = new List<Despacho>();
foreach (var cbte in comprobantesCDS)
{
Despacho itemDespacho = GetNewDespacho(cbte);
newDespachos.Add(itemDespacho);
}
inputDespachosWS.Despachos = newDespachos.ToArray();
//On the following line I receive the exception
CrearDespachos_Output output = clientWS.CrearDespachos(inputDespachosWS);
I attached the exception on execution CrearDespachos method Exception on runtime
ex.StackTrace
Server stack trace:
en System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
en System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
en System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
en System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
en System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
en System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
en System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
en System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
en System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
en ESAIntegracionesService.WSIntegracionCDS.IIntegracion.CrearDespachos(CrearDespachos_Input Input)
en ESAIntegracionesService.WSIntegracionCDS.IntegracionClient.CrearDespachos(CrearDespachos_Input Input) en C:\dev\esa-web\ESAIntegracionesService\Service References\WSIntegracionCDS\Reference.cs:línea 2691
en ESAIntegracionesService.Program.ActualizarComprobantes(String token) en C:\dev\esa-web\ESAIntegracionesService\Program.cs:línea 121
¿Could you help me?
Thanks a lot!
I am trying to access data via web service. My webservice calls works perfectly fine but sometimes it throws Fault occurred while processing the request. See fault detail for additional information exception
Here is my stacktrace of the error:
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
I have tried increasing the readerQuotas inside my binding. Here is how my bindings looks
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IWS" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
<readerQuotas
maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="TransportWithMessageCredential" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://xxxx.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWS"
contract="ABC.IWS" name="BasicHttpBinding_IWS" />
</client>
Am I missing some configuration here ?
I had the same issue and the solution is to set all parameter(s) of the service being called. With SOAPUI app you might NOT notice it once. But as always, fiddler says the truth. For example, at first you think that "important_parameters" are enough to set for calling the service. And you think web-service considers(/sets itself) "EndTo" parameter is 0... Wrong! You ought to set it deliberately, otherwise you get the error mentioned in this post.
...
<important_parameters>
....
</important_parameters>
<Paging>
<EndTo>0</EndTo>
</Paging>
...
For me the first troubleshooting step was to get more information on the error. Because of the way Task responses work, there can be many inner exceptions. So change the handling code to log the inner exceptions.
var responseTask = client.someRemoteCall(request);
responseTask.ContinueWith(t =>
{
switch (t.Status)
{
case TaskStatus.Faulted:
foreach (var exception in t.Exception.Flatten().InnerExceptions)
{
log.Error(exception.Message);
if (exception.InnerException != null)
{
log.Error(exception.InnerException.Message);
}
}
break;
case TaskStatus.RanToCompletion:
{your success code}
default:
{some deafult error is thrown}
}
});
This is my first WCF service project writing both client and server side. I'm from a Windows Forms background.
I think I've been having problems with packet/receive buffer size but I don't have a clue how to test whether my app.config is working correctly or what I've done wrong.
The client project's app.config is set as follows and it's testproj.exe.config reflects the contents correctly
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IPulseWebService"
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"
messageEncoding="Text" textEncoding="utf-8"
useDefaultWebProxy="true">
<readerQuotas
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxDepth="2147483647"
maxNameTableCharCount="2147483647"
maxStringContentLength="2147483647" />
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="blah"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IPulseWebService"
contract="ServiceReference1.IPulseWebService" name="WSHttpBinding_IPulseWebService">
<identity>
<dns value="localhst" />
</identity>
</endpoint>
</client>
</system.serviceModel>
My web service's webservice.dll.config contains the following service.serviceModel section
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IPulseWebService"
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"
messageEncoding="Text" textEncoding="utf-8"
useDefaultWebProxy="true">
<readerQuotas
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxDepth="2147483647"
maxNameTableCharCount="2147483647"
maxStringContentLength="2147483647" />
</binding>
</wsHttpBinding>
<basicHttpBinding>
<binding name="BasicHttpBinding_IPulseWebService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
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>
<services>
<service name="SmartcentreWcfLib.PulseWebService">
<host>
<baseAddresses>
<add baseAddress="http://l0calhost:8732/Design_Time_Addresses/SmartcentreWcfLib/PulseWebService/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IPulseWebService"
contract="SmartcentreWcfLib.IPulseWebService">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="l0calhost" />
</identity>
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True" />
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
In my server side wcf dll, I have the following function just as a test to return some rows of data. Each row is a set of key/value pairs stored in an Dictionary. Each object should be a simple byte[] or variable type.
List<IDictionary<string, object>> IAuditV1.ReadAuditForStaffMember(long staffId, DateTime startDate,
DateTime endDate, Int32 recordCount)
{
List<TableAdminAudit> tempResult = DatabaseInterface.Instance.AuditQueries.ReadAdminAudit(staffId, startDate,
endDate, recordCount);
return tempResult.Select(record => record.PrepareForWebInterface()).Cast<IDictionary<string, object>>().ToList();
}// function
In my client application I am running the following loop, which simply increments the number of received records.
Int32 totalRecords = 0;
while (true)
{
results = client.ReadAuditForStaffMember(1, DateTime.MinValue, DateTime.Now, totalRecords);
totalRecords += 10; //results.Length;
if (totalRecords == 0) break;
}
On the 3rd loop when the returned buffer reaches 30 records in size I receive the following error message.
I looked up the error and forums suggested it relates to the connection closing before the whole data had been received so change the various buffer sizes etc. As you can see from my config files, I've upped all the values I'm aware of to 2147483647 but it's not worked.
So I don't know where to go from here. Can anybody help please?
System.ServiceModel.CommunicationException occurred
HResult=-2146233087
Message=An error occurred while receiving the HTTP response to blah2/Design_Time_Addresses/SmartcentreWcfLib/PulseWebService/. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.
Source=mscorlib
StackTrace:
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.RequestClientReliableChannelBinder`1.OnRequest(TRequestChannel channel, Message message, TimeSpan timeout, MaskingMode maskingMode)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout, MaskingMode maskingMode)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at WcfTester.ServiceReference1.IPulseWebService.ReadAuditForStaffMember(Int64 staffId, DateTime startDate, DateTime endDate, Int32 startIndex)
at WcfTester.ServiceReference1.PulseWebServiceClient.ReadAuditForStaffMember(Int64 staffId, DateTime startDate, DateTime endDate, Int32 startIndex) in W:\Projects\pulse.smartcentre.root\pulse.smartcentre\WcfTester\Service References\ServiceReference1\Reference.cs:line 481
at WcfTester.Program.Main(String[] args) in W:\Projects\pulse.smartcentre.root\pulse.smartcentre\WcfTester\Program.cs:line 40
InnerException: System.Net.WebException
HResult=-2146233079
Message=The underlying connection was closed: An unexpected error occurred on a receive.
Source=System
StackTrace:
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
InnerException: System.IO.IOException
HResult=-2146232800
Message=Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
Source=System
StackTrace:
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
InnerException: System.Net.Sockets.SocketException
HResult=-2147467259
Message=An existing connection was forcibly closed by the remote host
Source=System
ErrorCode=10054
NativeErrorCode=10054
StackTrace:
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
InnerException:**
The file something.dll.config is never used. You need to copy those settings into the web.config or servicehost.exe.config file.
This is how .NET has worked since Day 1, and is not specific to WCF. Consider that a given DLL can be used by multiple "executables", and each of these may have different settings for the DLL.
I've created wcf service and everything works correctly but when i try to return Type[] (i got it from Assembly.GetTypes()) i have following exception:
System.ServiceModel.CommunicationException: The underlying connection was closed: The connection was closed unexpectedly.
---> System.Net.WebException: The underlying connection was closed: The connection was closed unexpectedly.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
--- End of inner exception stack trace ---
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at ConsoleApplication1.ServiceReference1.IWcfAssembly.GetAssemblyTypes(String a)
at ConsoleApplication1.ServiceReference1.WcfAssemblyClient.GetAssemblyTypes(String a) in D:\Projekty\ConsoleApplication1\ConsoleApplication1\Service References\ServiceReference1\Reference.cs:line 50
at ConsoleApplication1.Program.Main(String[] args) in D:\Projekty\ConsoleApplication1\ConsoleApplication1\Program.cs:line 17
I thought it might be maxItemsInObjectGraph property or maxArrayLenght (and similar) but it didn't help. Still got the same exception. Maybe I did something wrong with the property declaration?
this is my client config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IWcfAssembly" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="128" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="4096" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:57040/WcfAssembly.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IWcfAssembly" contract="ServiceReference1.IWcfAssembly"
name="BasicHttpBinding_IWcfAssembly" />
</client>
</system.serviceModel>
</configuration>
and this is my service config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IWcfAssembly" receiveTimeout="00:10:00" sendTimeout="00:10:00" openTimeout="00:10:00" closeTimeout="00:10:00"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="52428899">
<readerQuotas maxDepth="128"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="4096"
maxNameTableCharCount="2147483647" />
<security mode="None"/>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
I have also added [ServiceBehavior(MaxItemsInObjectGraph = int.MaxValue)] as a class attribute. I had it in my service config before but this is one of tries.
Do you have any ideas guys? Why the array returned from Assembly.GetTypes() causes such error? (big array of int[] works OK)
The problem is that the System.RunTimeType is not serialize (which is in the internal implementation of Type)
using this mock:
void Main()
{
var dto = new MyDto();
dto.Tada = new Type[] { this.GetType() };
DataContractSerializer ser =
new DataContractSerializer(typeof(MyDto));
var ms = new MemoryStream();
ser.WriteObject(ms, dto);
ms.Dump();
dto.Dump();
}
public class MyDto
{
public Type[] Tada { get; set; }
}
Throws:
SerializationException: Type 'System.RuntimeType' with data contract
name 'RuntimeType:http://schemas.datacontract.org/2004/07/System' is
not expected. Consider using a DataContractResolver or add any types
not known statically to the list of known types - for example, by
using the KnownTypeAttribute attribute or by adding them to the list
of known types passed to DataContractSerializer.
Which makes sense because RunTimeType is internal (Type itself is abstract). You have to come up with your own serialized type that can convey the info you want.
I try to load magento web service from https://myclient.com/api/v2_soap/index/wsdl/1 into my .net console testing application. I added service reference and it generated basichttpbinding in the app.config file with the endpoint.
however when i tried to login, i got this error: "SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://myclient.com/index.php/api/v2_soap/index/wsdl/1/' : Start tag expected, '<' not found"
Any ideas?
System.ServiceModel.FaultException was unhandled
HResult=-2146233087
Message=SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://myclient.com/index.php/api/v2_soap/index/wsdl/1/' : Start tag expected, '<' not found
Source=mscorlib
StackTrace:
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
app.config:
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Mage_Api_Model_Server_V2_HandlerBinding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
maxBufferPoolSize="524288000" maxBufferSize="65536000" maxReceivedMessageSize="65536000">
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://myclient.com/api/v2_soap/index/wsdl/1"
binding="basicHttpBinding" bindingConfiguration="Mage_Api_Model_Server_V2_HandlerBinding"
contract="TattyService.Mage_Api_Model_Server_V2_HandlerPortType"
name="Mage_Api_Model_Server_V2_HandlerPort" />
</client>
</system.serviceModel>
</configuration>
program.cs:
using (Mage_Api_Model_Server_V2_HandlerPortTypeClient proxy = new Mage_Api_Model_Server_V2_HandlerPortTypeClient())
{
proxy.login("username", "apikey");
}
By this phrase of the error "Start tag expected, '<' not found", the basic problem must be the missing of the XML Start tag in probably the Magento file "wsdl.xml".
I practically don't know the easiest solution, but you can definitely go through each line manually after you have loaded the WSDL in your browser successfully. Based on the line of the error, you will have to identify the Magento module, and then rectify this defect.
Hope it helps.
it turned out to be the web host added extra layer of SSL which most of machine doesn't have it installed. that's when browser can browse it but not VS.