xml - Replacing content of WCF Message -


I am trying to set up a routing service that will sit in the DMZ of my network, and access external users Will allow some internal WCF hosting services. I have everything set up and working, but when I move on to MEX services, it points to our external customers at our internal address, which they can not explicitly access.

, which will probably work, but every time I change the service definitions, we will need to make a new copy of wsdl, which they often do and seems like overkill, only one thing needs to be changed. That's an address in the Mac message.

  End Lieutenant Address = "http: // appsrv1: 8781 / ProcessNameServ /" binding = "wsHttpBinding" binding configuration = "WSHttpBinding_IProcessManagementService" contract = "IProcessManagementService" name = "WSHttpBinding_IProcessManagementService" /> ; It seems that using a  IDispatchMessageInspector , I should be able to stop the Max Message and change the internal server name with the external server name, and then whenever I make any changes, Rather, when I need to add or remove a service, touch the routing service.  

I do not have much experience with XML readers, writers and so on, so I am looking for some guidance on how to proceed. If I could just read the XML content in the string, then I could do a replacement job instead of the external address option for the internal one, then replacing the reply message content with my revised version. How can I go about doing this, or is there a better way to modify WCF message content?

EDIT: So it is that I have mudded this far together.

  Public Class Intermediate Inspector: IDispatchMessage Inspector {RéceiveRequest (Riff Message Request, IClientChannel Channel, InstanceContext instanceContext) after the public object {return tap; } Send public before zero (message per message, object correlation:) {var ms = new MemoryStream (); Var w = XmlWriter.Create (MS, New XmlWriterSettings {Indent = true, Indent Chars = "", OmitXmlDeclaration = true}); Var bodyReader = Answer GetReaderAtBodyContents (); W.WriteStartElement ("s", "body", "http://schemas.xmlsoap.org/soaf/envelope/"); While (bodyReader.NodeType! = XmlNodeType.EndElement & amp; amp; BodyRedder.LocalName! = "Body" & Body Reader. Name Pass URI! = "Http://schemas.xmlsoap.org/soap/envelope/") { If (BodyReader.NodeType! = XmlNodeType.Whitespace) {w.WriteNode (bodyReader, true); } And {bodyReader.Read (); // ignore whitespace; If you want to maintain}} w.WriteEndElement (); W.flush (); Var body = encoding. UTF8.GetString (ms.ToArray ()); Body = body Change ("InternalSaver", "ExtnLerser"); Message = Message in place of Var. Create Message (XmlReader.Create (New StringRedder (body)), int.MaxValue, Answer Version;); ReplacedMessage.Headers.CopyHeadersFrom (reply.Headers); ReplacedMessage.Properties.CopyProperties (reply.Properties); Answer = Replaced Message; }}   

And it seems that mostly work, however, XMLReader is throwing an exception "data at the basic level invalid Line 1, position 1. " When I try to create a message, I do not know how to get started on it

Edit 2:

OK, now I have found a way to get the message Removes an ExDime, then it sends a string, then edits it, and pulls it back an xdocument, and I get a "connection forced" when I return the message that contains the edited message Is awesome

Edit 3:

After the test, just remove the message from the answer of the ExDock and then load it in a new message to "force connection closed" issue. It should not be the right way to edit the messages. I am looking at these examples or experiences about how this is the best way.

I got the answer. My problem was that I was changing the length of the string, but not to reset the length of MemoryStream, which means that the bytes were not being reported at the end.

Here is a work replacement function.

  public messaging string (message from old message, string, string) {MemoryStream ms = new MemoryStream (); Xmlr xw = xmlrrr Serate (ms); OldMessage.WriteMessage (xw); Xw.flush (); String body = encoding. UTF8.GetString (ms.ToArray ()); Xw.Close (); Body = body Place (from, to); MS = new memorystream (encoding. UTF8.GetBytes (body)); XmlDictionaryReader xdr = XmlDictionaryReader.CreateTextReader (MS, New XmlDictionaryReaderQuotas ()); Message newMessage = message. Create message (xdr, int.maxValue, old messaging version); NewMessage.Properties.CopyProperties (oldMessage.Properties); Return a new message; }    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -