c# - Service Stack Serialization Exception for soap 1.1 -
the request message:
<soap:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:body> <sendgetaccountnotification xmlns:i="http://www.w3.org/2001/xmlschema-instance" xmlns="mynamespace"> <getaccountresponse xmlns:d2p1="mynamespace"> <d2p1:account> <d2p1:busopsdesc>string</d2p1:busopsdesc> <d2p1:externalaccountid>string</d2p1:externalaccountid> </d2p1:account> <d2p1:externalaccountid>string</d2p1:externalaccountid> <d2p1:message>string</d2p1:message> </getaccountresponse> </sendgetaccountnotification> </soap:body> </soap:envelope>
response message / error:
<sendgetaccountnotificationresponse xmlns:i="http://www.w3.org/2001/xmlschema-instance" xmlns="mynamespace"> <responsestatus> <errorcode>serializationexception</errorcode> <message>could not deserialize 'application/xml' request using eservices_response.sendgetaccountnotification' error: system.runtime.serialization.serializationexception: error in line 1 position 170. expecting element 'sendgetaccountnotification' namespace 'mynamespace'.. encountered 'element' name 'envelope', namespace 'http://schemas.xmlsoap.org/soap/envelope/'. @ system.runtime.serialization.datacontractserializer.internalreadobject(xmlreaderdelegator xmlreader, boolean verifyobjectname, datacontractresolver datacontractresolver) @ system.runtime.serialization.xmlobjectserializer.readobjecthandleexceptions(xmlreaderdelegator reader, boolean verifyobjectname, datacontractresolver datacontractresolver) @ servicestack.webhost.endpoints.support.endpointhandlerbase.deserializecontenttype(type operationtype, ihttprequest httpreq, string contenttype)</message> <stacktrace>at servicestack.webhost.endpoints.support.endpointhandlerbase.deserializecontenttype(type operationtype, ihttprequest httpreq, string contenttype) @ servicestack.webhost.endpoints.generichandler.processrequest(ihttprequest httpreq, ihttpresponse httpres, string operationname)</stacktrace> </responsestatus> </sendgetaccountnotificationresponse>
the c# service:
[datacontract(namespace = "mynamespace")] public class sendgetaccountresponseservice : iservice<sendgetaccountnotification> { public object execute (sendgetaccountnotification request) { console.writeline ("reached"); return null; } }
question:
okay have been digging around hours , cant find solution. inserted request xml soap ui , got error response. looks not soap envelope , trying serialize request starting not taking in regard ignore envelope , serialize soap body model. have no idea why happening, else know? need add attributes in somewhere perhaps? appreciated.
solution:
look green tick. solved checking endpoint, pointing xml endpoint , therefore getting error message. have improved service following post solved problem. noticed had older version of service stack updated , works charm.
below (simplified) attempt @ service. ignores 'namespace' there more information here. able receive successful response using soap ui.
soapui setup:
endpoint - http://localhost:1337/soap11
request message: (copied servicestack metadata page)
<soap:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:body> <sendgetaccountnotification xmlns:i="http://www.w3.org/2001/xmlschema-instance" xmlns="http://schemas.datacontract.org/2004/07/servicestackwinform"> <account> <busopsdesc>string</busopsdesc> <externalaccountid>12345</externalaccountid> </account> <externalaccountid>string</externalaccountid> <message>string</message> </sendgetaccountnotification> </soap:body> </soap:envelope>
servicestack code:
account class (part of request):
[datacontract] public class account { [datamember] public string busopsdesc { get; set; } [datamember] public string externalaccountid { get; set; } }
request class
[datacontract] [route("/sendgetaccountnotification")] public class sendgetaccountnotification { [datamember] public account account { get; set; } [datamember] public string externalaccountid { get; set; } [datamember] public string message { get; set; } }
response class matching naming convention
[datacontract] public class sendgetaccountnotificationresponse : ihasresponsestatus { [datamember] public string result { get; set; } [datamember] public responsestatus responsestatus { get; set; } }
service
public class sendgetaccountresponseservice : service { public sendgetaccountnotificationresponse any(sendgetaccountnotification request) { console.writeline("reached"); return new sendgetaccountnotificationresponse() {result = "success account " + request.account.externalaccountid}; } }
Comments
Post a Comment