WCF Service m. JSon virker ikke når det er uploadet.
Hey drengene.Sidder og leger lidt med noget Silverlight hjemmeside. Til det benytter jeg en WCF Service.
WCF Servicen trækker nogle JSon objekter, og så skal noget logik så sørge for at disse objekter kommer frem i kommentarfelterne på siden.
Dette virker ! ... lokalt!
Når jeg publisher siden virker det ikke, og jeg får følgende fejl.
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3)
Timestamp: Sun, 10 Apr 2011 01:10:21 UTC
Message: Unhandled Error in Silverlight Application An exception occurred during the operation, making the result invalid. Check InnerException for exception details.
at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
at SharpProgramming.CommentService.GetCommentListCompletedEventArgs.get_Result()
at SharpProgramming.Views.CommentsPage.crt_GetCommentListCompleted(Object sender, GetCommentListCompletedEventArgs e)
at
SharpProgramming.CommentService.CommentRetrievalServiceClient.OnGetCommentListCompleted(Object state)
Line: 1
Char: 1
Code: 0
URI: http://sharpprogramming.net/Silverlight.js
Jeg sad og overvejede om det var grundet at den service jeg havde oprettet altid kalder Localhost, og den jo gerne skulle have fat i hjemmesiden. Så prøvede at uploade servicen og derefter lave den som reference. Men modtager denne fejl.
The document at the url http://www.sharpprogramming.net/CommentRetrievalService.svc was not recognized as a known document type.
The error message from each known type may help you fix the problem:
- Report from 'XML Schema' is 'Name cannot begin with the '%' character, hexadecimal value 0x25. Line 1, position 2.'.
- Report from 'DISCO Document' is 'Name cannot begin with the '%' character, hexadecimal value 0x25. Line 1, position 2.'.
- Report from 'WSDL Document' is 'There is an error in XML document (1, 2).'.
- Name cannot begin with the '%' character, hexadecimal value 0x25. Line 1, position 2.
Metadata contains a reference that cannot be resolved: 'http://www.sharpprogramming.net/CommentRetrievalService.svc'.
The content type text/plain of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 149 bytes of the response were: '<%@ ServiceHost Language="C#" Debug="true" Service="SharpProgramming.Web.CommentRetrievalService" CodeBehind="CommentRetrievalService.svc.cs" %>
'.
If the service is defined in the current solution, try building the solution and adding the service reference again.
Jeg bruger godt nok text/plain i mit .php hvor jeg forbinder til databasen. Men, det gør ingen forskel om det er der eller ej.
Ved ikke om det er noget meget simpel jeg har overset, men har ikke pillet med JSon og WCF Services før.
Så håber der er hjælp at hente.
Hvis der er nogle kodestumper i føler kunne være nyttige at se, så sig til, så poster jeg dem med det samme.
Her er et udkast af mit ServiceReference.ClientConfig
Hvis det skulle hjælpe lidt.
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="UserBasicHTTPBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security>
<transport>
<extendedProtectionPolicy policyEnforcement="Never"/>
</transport>
</security>
</binding>
</basicHttpBinding>
<customBinding>
<binding name="CustomBinding_CommentRetrievalService">
<binaryMessageEncoding />
<httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://localhost:51608/CommentRetrievalService.svc"
binding="customBinding" bindingConfiguration="CustomBinding_CommentRetrievalService"
contract="CommentService.CommentRetrievalService" name="CustomBinding_CommentRetrievalService" />
</client>
</system.serviceModel>
</configuration>