Search Results

Search found 18472 results on 739 pages for 'vtd xml author'.

Page 40/739 | < Previous Page | 36 37 38 39 40 41 42 43 44 45 46 47  | Next Page >

  • Load php file wth xml header

    - by John Smith
    I have a php file with an xml header and xml code, named test.php. How do I load this file as an xml? The following doesn't work: $xml = simplexml_load_file('test.php'); echo $xml; I just get a white page. The test file is saved as php, as it's dynamic. It's loading data from the tradedoubler api. The xml looks something like this: <voucherList> <voucher> <id>115</id> <programId>111</programId> <programName>Program 111</programName> <code>AF30C5</code> <updateDate>1332422674941</updateDate> <startDate>1332370800000</startDate> <endDate>1363906800000</endDate> <title>Voucher number one</title> <shortDescription>Short description of the voucher.</shortDescription> <description>This is a long version of the voucher description.</description> <voucherTypeId>1</voucherTypeId> <defaultTrackUri>http://clk.tradedoubler.com/click?a(222)p(111)ttid(13)</defaultTrackUri> <siteSpecific>True</siteSpecific> </voucher> <voucher> <id>116</id> <programId>111</programId> <programName>Program 111</programName> <code>F90Z4F</code> <updateDate>1332423212631</updateDate> <startDate>1332370800000</startDate> <endDate>1363906800000</endDate> <title>The second voucher</title> <shortDescription>Short description of the voucher.</shortDescription> <description>This is a long version of the voucher description.</description> <voucherTypeId>1</voucherTypeId> <defaultTrackUri>http://clk.tradedoubler.com/click?a(222)p(111)ttid(13)url(http://www.example.com/product?id=123)</defaultTrackUri> <siteSpecific>False</siteSpecific> <landingUrl>http://www.example.com/product?id=123</landingUrl> </voucher> </voucherList>

    Read the article

  • Obtaining XML from U.S. Postal Service (USPS) rate calculator API with PHP

    - by Chris F
    hoping somebody here can help me. I'm attempting to pull an XML page from the U.S. Postal Service (USPS) rate calculator, using PHP. Here is the code I am using (with my API login and password replaced of course): <? $api = "http://production.shippingapis.com/ShippingAPI.dll?API=RateV4&XML=<RateV4Request ". "USERID=\"MYUSERID\" PASSWORD=\"MYPASSWORD\"><Revision/><Package ID=\"1ST\">". "<Service>FIRST CLASS</Service><FirstClassMailType>PARCEL</FirstClassMailType>". "<ZipOrigination>12345</ZipOrigination><ZipDestination>54321</ZipDestination>". "<Pounds>0</Pounds><Ounces>9</Ounces><Container/><Size>REGULAR</Size></Package></RateV4Request>"; $xml_string = file_get_contents($api); $xml = simplexml_load_string($xml_string); ?> Pretty straightforward. However it never returns anything. I can paste the URL directly into my browser's address bar: http://production.shippingapis.com/ShippingAPI.dll?API=RateV4&XML=<RateV4RequestUSERID="MYUSERID" PASSWORD="MYPASSWORD"><Revision/><Package ID="1ST"><Service>FIRST CLASS</Service><FirstClassMailType>PARCEL</FirstClassMailType><ZipOrigination>12345</ZipOrigination><ZipDestination>54321</ZipDestination><Pounds>0</Pounds><Ounces>9</Ounces><Container/><Size>REGULAR</Size></Package></RateV4Request> And it returns the XML I need, so I know the URL is valid. But I cannot seem to capture it using PHP. Any help would be tremendously appreciated. Thanks in advance.

    Read the article

  • receive xml file as a parameter to a .net web service

    - by fizch
    My company is currently looking into bringing a new piece of third party software in for online ordering. The software does not handle pricing so they are requesting the pricing information from a web service. Their software is passing an XML file as a parameter, and expecting an XML file as a response. I would think that returning an XML file would be pretty straight forward, but I cannot think of a way to receive an XML file as a parameter. Has anyone done this, or am I missing something really obvious?

    Read the article

  • Java: Writing a DOM to an XML file (formatting issues)

    - by Vhaerun
    I'm using org.w3c XML API to open an existing XML file. I'm removing some nodes , and I'm adding others instead . The problem is that the new nodes that are added are written one after another , with no newline and no indentation what so ever. While it's true that the XML file is valid , it is very hard for a human to examnine it. Is there anyway to add indentation , or at least a newline after each node ?

    Read the article

  • xml parsing takes extra spaces.

    - by SDK
    I have been trying to write/parse xml file in python. The tags are very simple <main> <data> abcdef </data> </main> I have written this xml using xml document writer from xml.dom.minidom. How-ever when i try to parse this and try to fetch data-text value, i get 'abcdef' with spaces/carriage return/newline characters in beg and end. Does parsing does not take of indenting spaces? Following is the parsing snippet (ref from net) dom = parseString(data) clipTag = dom.getElementsByTagName('clipdata')[0].toxml() clipData=clipTag.replace('<clipdata>','').replace('</clipdata>','') Kindly suggest.

    Read the article

  • Android Java error handling XML file

    - by Paul
    I'm using SAX and XML reader to read XML weather info from the web and it works fine if the page exists. But if for instance the user inputs an invalid city, zip etc the XML page that gets read from is empty and the app force closes with nullpointerexception. The area that generates the error is here right at open inputstream. Any suggestions?: SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = null; try { sp = spf.newSAXParser(); } catch (ParserConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } /* Get the XMLReader of the SAXParser we created. */ XMLReader xr = null; try { xr = sp.getXMLReader(); } catch (SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } /* Create a new ContentHandler and apply it to the XML-Reader*/ WeatherHandler myExampleHandler = new WeatherHandler(); xr.setContentHandler(myExampleHandler); /* Parse the xml-data from our URL. */ try { xr.parse(new InputSource(url.openStream())); parsedWeatherDataSet = myExampleHandler.getParsedData(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } return parsedWeatherDataSet.toString();

    Read the article

  • Invalid XML Replace Content in PHP

    - by streetparade
    I have a invalid XML like this Warning: count() [function.count]: Node no longer exists in /var/bla/test.php <?xml version="1.0" encoding="ISO-8859-1"?> <nodes> <some>test</some> </nodes> Now i need a regex which would replace the Warning: count() [function.count]: Node no longer exists in /var/bla/test.php with "" how can i do that? The above xml is is not generated on my localmachine, its a api call which returned a invalid xml

    Read the article

  • Editing XML file content with Python.

    - by Hooloovoo
    Hi, I am trying to use Python to read in an XML file containing some parameter names and values, e.g. ... <parameter name='par1'> <value>24</value> </parameter> <parameter name='par2'> <value>Blue/Red/Green</value> </parameter> ... and then pass it a dictionary with the parameter names {'par1':'53','par2':'Yellow/Pink/Black',...} and corresponding new values to replace the old ones in the XML file. The output should then overwrite the original XML file. At the moment I am converting the XML to a python dictionary and after some element comparison and regular expression handling, writing the output again in XML format. I am not too happy with this and was wondering whether anyone can recommend a more efficient way of doing it? Thanks.

    Read the article

  • xml cache on iphone

    - by dubbeat
    Hi, Could somebody suggest a technique or class library to read up on for XML Caching on the iphone? The biggest lag in my app is the XML being downloaded from the server. If a user views a screen the xml has to be downloaded and parsed and theres a wait of a few seconds. If they leave the screen and come back to it again they have to wait all over again which is kinda crappy.

    Read the article

  • Succinct LINQ to XML Query

    - by Kent Boogaart
    Assuming you have the following XML: <?xml version="1.0" encoding="utf-8"?> <content> <info> <media> <image> <info> <imageType>product</imageType> </info> <imagedata fileref="http://www.example.com/image1.jpg" /> </image> <image> <info> <imageType>manufacturer</imageType> </info> <imagedata fileref="http://www.example.com/image2.jpg" /> </image> </media> </info> </content> Using LINQ to XML, what is the most succinct, robust way to obtain a System.Uri for an image of a given type? At the moment I have this: private static Uri GetImageUri(XElement xml, string imageType) { return (from imageTypeElement in xml.Descendants("imageType") where imageTypeElement.Value == imageType && imageTypeElement.Parent != null && imageTypeElement.Parent.Parent != null from imageDataElement in imageTypeElement.Parent.Parent.Descendants("imagedata") let fileRefAttribute = imageDataElement.Attribute("fileref") where fileRefAttribute != null && !string.IsNullOrEmpty(fileRefAttribute.Value) select new Uri(fileRefAttribute.Value)).FirstOrDefault(); } This works, but feels way too complicated. Especially when you consider the XPath equivalent. Can anyone point out a better way?

    Read the article

  • convert &lt to < xml document

    - by Lenin Lourembam
    Hi, I have read an XML file and converted into NSXMLDocument object. But, due to the presence of "<" in the string content of a node, it has been converted into "&lt". So, when i write it as xml document to a file, it has the character "&lt" in it. How can i write to the file as ordinary XML file in which "&lt" will be replaced by "<". Thanks and Regards, Lenin

    Read the article

  • Java, UnmarshallingException caused by XML attribute with special chars: ;ìè+òàù-<^èç°§_>!£$%&/()=?~

    - by segolas
    Hi, my xml file has a tag with an attribute "containsValue" which contains the "special" characters you can see in the subject: <original_msg_body id="msgBodySpecialCharsRule" containsValue=";ìè+òàù-<^èç°§_>!£$%&/()=?~`'#;" /> in my xml schema the attribute has xs:string: <xs:attribute name="containsValue" type="xs:string" /> I use this value inside a Java software which check if this value is contained inside another String. but I always obtain this Exception: javax.xml.bind.UnmarshalException - with linked exception: [org.xml.sax.SAXParseException: The value of attribute "containsValue" associated with an element type "original_msg_body" must not contain the '<' character.] How can I solve it? I've tried changing the attribute type to xs:NMTOKEN, ut I get the same exception. Is there any other type? I think I could change the characters encoding, for example using the HTML representation, like <, but than could be tricky for the string comparison...

    Read the article

  • Author Bio on all pages - Is it duplicate content?

    - by Rana Prathap
    In a website with user generated content, I provide a author bio under every article on the site. The author bio will be the same under every article the same author wrote. For some authors, the author bio is no longer then a couple of sentences, but for some descriptive writers, it is a good 100 words. These 100 words get repeated in almost 15 pages, some of them without substantial original content(such as haikus). Will this lead to duplicate content?

    Read the article

  • Is there a standard Java utility to parse XSD files at runtime?

    - by Andrew
    I've been looking around for a way to programmatically parse XSD files to generate an XML mapping so that I can take any XSD file and create a parser that will parse any XML file that conforms to it, and my google-fu has been coming up short. XSOM looks promising, as it will parse an XSD file and make all its attributes available in a straight forward way. Are there any other options or standard libraries available that will produce an XML file parser from an XSD file? [Conclusion] Thanks everyone for your responses, they were a real help. I was able to write implementations using JAXP, Eclipses EMF and in XSOM that all worked as desired. JAXP was very straight forward and easy to learn and do. EMF was actually a pain to get going properly, there were so many jars that had to be included for it to work standalone that I would not recommend it. XSOM was even simpler than the JAXP implementation, so I went with it in the end.

    Read the article

  • VB.NET, make a function with return type generic ?

    - by Quandary
    Currently I have written a function to deserialize XML as seen below. How do I change it so I don't have to replace the type every time I want to serialize another object type ? The current object type is cToolConfig. How do I make this function generic ? Public Shared Function DeserializeFromXML(ByRef strFileNameAndPath As String) As XMLhandler.XMLserialization.cToolConfig Dim deserializer As New System.Xml.Serialization.XmlSerializer(GetType(cToolConfig)) Dim srEncodingReader As IO.StreamReader = New IO.StreamReader(strFileNameAndPath, System.Text.Encoding.UTF8) Dim ThisFacility As cToolConfig ThisFacility = DirectCast(deserializer.Deserialize(srEncodingReader), cToolConfig) srEncodingReader.Close() srEncodingReader.Dispose() Return ThisFacility End Function Public Shared Function DeserializeFromXML1(ByRef strFileNameAndPath As String) As System.Collections.Generic.List(Of XMLhandler.XMLserialization.cToolConfig) Dim deserializer As New System.Xml.Serialization.XmlSerializer(GetType(System.Collections.Generic.List(Of cToolConfig))) Dim srEncodingReader As IO.StreamReader = New IO.StreamReader(strFileNameAndPath, System.Text.Encoding.UTF8) Dim FacilityList As System.Collections.Generic.List(Of cToolConfig) FacilityList = DirectCast(deserializer.Deserialize(srEncodingReader), System.Collections.Generic.List(Of cToolConfig)) srEncodingReader.Close() srEncodingReader.Dispose() Return FacilityList End Function

    Read the article

  • JAXB appending unneeded namespace declarations to tags

    - by jb
    I'm implementing a homebrew subprotocol of XMPP, and i'm using combination of StAX and JAXB for parsing/marshalling mesages. And when I marshall a message I end up with loads of unneded namespace declarations: <ns2:auth xmlns:ns2="urn:ietf:params:xml:ns:ilf-auth" xmlns:ns4="ilf:iq:experiment:power" xmlns:ns3="ilf:iq:experiment:init" xmlns:ns5="ilf:iq:experiment:values" xmlns:ns6="ilf:iq:experiment:result" xmlns:ns7="ilf:iq:experiment:stop" xmlns:ns8="ilf:iq:experiment:end"> compton@ilf</ns2:auth> instead of: <ns:auth xmlns:ns="urn:ietf:params:xml:ns:ilf-auth>compton@ilf</ns:auth> Is there any way to turn that of? All these namespaces are used in different messages that get marshalled/unmarshalled by JAXB, but every message uses one namespace. PS. I am not an XML expert please dont rant me if I did some stupid mistake ;)

    Read the article

  • Does Altova StyleVision support generation of these specific Word XML Word ML List Numbering Bullet Markup? Extend with custom external XSLT?

    - by Alex S
    Does Altova StyleVision support generation of these specific Word XML Word ML List Numbering Bullet Markup? Extend with custom external XSLT? PS: I know is specific to Altova and their Dev Tools, but just like Eclipse and Visual Studio it is one of the widest used toolkits for XML related development & programming. So, please do not hate, ban or give negative. Linked below is a section of information for Word ML XML and its numbering, list, bullet etc. The markup is pretty extensive. I am wondering if this can be replicated via StyleVision or is this a limitation that needs to extended with an external XSLT? Quote: Key links to the Markup Documentation: http://officeopenxml.com/WPnumbering.php http://officeopenxml.com/WPnumberingAbstractNum.php Also: /WPnumberingLvl.php Short outline of the Documentation there: *Numbering, Levels and Lists* - Overview - Defining a Numbering Scheme - Defining a Particular Level ++ Numbering Level Text ++ Numbering Format ++ Displaying as Numerals Only ++ Restart Numbering ++ Picture or Image as Numbering Symbol ++ Justification ++ Overriding a Numbering Definition If StyleVision supports the above, where and how inside StyleVision can I access or use these properties/ attributes for the markup? From what I've gathered, I think it does not. In the past, I have written XSL-FO and XSL-WordML by hand. So I could write an add-on external XSLT containing Word specific markup for this purpose. *Given the limitation exists, the questions now: * Where and how do I create and linked inside of StyleVision so as to APPLY and EXTEND these capability limitations of StyleVision. AND How could I make it apply only for Word ML / Word XML output styling and be DEACTIVATED/ DISABLED for HTML and PDF output?

    Read the article

  • Using XSD file in VS2005

    - by xt_20
    Hello all I want to write an XML file. I have created an XSD file named XMLSchema.xsd, and run the command 'xsd /c XMLSchema.xsd' which generated a c# class file. Now, how do I use this file to generate XML files? Part of my code: <?xml version="1.0" encoding="utf-8"?> <xs:schema id="XMLSchema" targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd" > <xs:element name="root"> <xs:complexType> <xs:sequence> <xs:element name="Audit"> <xs:complexType> ... which generates a c# class 'root'. How do I call 'root' from my C# web program? Thanks

    Read the article

  • What are the advantages of storing xml in a relational database?

    - by Chris
    I was poking around the AdventureWorks database today and I noticed that a number of tables (HumanResources.JobCandidate and Sales.Individual for example) have a column which is storing xml data. What I would to know is, what is the advantage of storing basically a database table row's worth of data in another table's column? Doesn't this make it difficult to query off of this information? Or is the assumption that the data won't need to be queried and just needs to be stored?

    Read the article

  • What are the advantages of storing xml in a relational database?

    - by Chris
    I was poking around the AdventureWorks database today and I noticed that a number of tables (HumanResources.JobCandidate and Sales.Individual for example) have a column which is storing xml data. What I would to know is, what is the advantage of storing basically a database table row's worth of data in another table's column? Doesn't this make it difficult to query off of this information? Or is the assumption that the data won't need to be queried and just needs to be stored?

    Read the article

  • JAXB adding namespace to parent but not to the child elements contained

    - by Nishant
    I put together an XSD and used JAXB to generate classes out of it. Here are my XSDs- myDoc.xsd : <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns="http://www.mydoc.org" targetNamespace="http://www.mydoc.org" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mtp="http://www.mytypes.com" elementFormDefault="qualified"> <xs:import namespace="http://www.mytypes.com" schemaLocation="mytypes.xsd" /> <xs:element name="myDoc"> <xs:complexType> <xs:sequence> <xs:element name="crap" type="xs:string"/> <xs:element ref="mtp:foo"/> <xs:element ref="mtp:bar"/> </xs:sequence> </xs:complexType> </xs:element> mytypes.xsd <?xml version="1.0" encoding="UTF-8"?> <xs:schema targetNamespace="http://www.mytypes.com" xmlns="http://www.mytypes.com" xmlns:tns="http://www.mytypes.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified"> <xs:element name="foo" type="tns:Foo"/> <xs:element name="bar" type="tns:Bar"/> <xs:element name="spam" type="tns:Spam"/> <xs:simpleType name="Foo"> <xs:restriction base="xs:string"></xs:restriction> </xs:simpleType> <xs:complexType name="Bar"> <xs:sequence> <xs:element ref="spam"/> </xs:sequence> </xs:complexType> <xs:simpleType name="Spam"> <xs:restriction base="xs:string" /> </xs:simpleType> </xs:schema> The document marshalled is- <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <myDoc xmlns:ns2="http://www.mytypes.com"> <crap>real crap</crap> <ns2:foo>bleh</ns2:foo> <ns2:bar> <spam>blah</spam> </ns2:bar> </myDoc> Note that the <spam> element uses the default namespace. I would like it to use the ns2 namespace. The schema (mytypes.xsd) expresses the fact that <spam> is contained within <bar> which in the XML instance is bound to the ns2 namespace. I've broken my head over this for over a week and I would like ns2 prefix to appear in <spam>. What should I do? Required : <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <myDoc xmlns:ns2="http://www.mytypes.com"> <crap>real crap</crap> <ns2:foo>bleh</ns2:foo> <ns2:bar> <ns2:spam>blah</ns2:spam><!--NS NS NS--> </ns2:bar> </myDoc>

    Read the article

  • Recursive XSD Help

    - by Alon
    Hi, i'm trying to learn a little bit XSD and I'm trying to create a XSD for this xml: <Document> <TextBox Name="Username" /> <TextBox Name="Password" /> </Document> ... so there's an element, which is an abstract complex type. Every element have elements and so on. Document and TextBox are extending Element. I trid this: <?xml version="1.0" encoding="utf-8" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Document"> <xs:complexType> <xs:complexContent> <xs:extension base="Element"> </xs:extension> </xs:complexContent> </xs:complexType> </xs:element> <xs:complexType name="Element" abstract="true"> <xs:sequence minOccurs="0" maxOccurs="unbounded"> <xs:element name="Element" type="Element"></xs:element> </xs:sequence> </xs:complexType> <xs:complexType name="TextBox"> <xs:complexContent> <xs:extension base="Element"> <xs:attribute name="Name" type="xs:string" /> </xs:extension> </xs:complexContent> </xs:complexType> </xs:schema> I compiled it to C# with Xsd2Code, and now I try to deserialize it: var serializer = new XmlSerializer(typeof(Document)); var document = (Document)serializer.Deserialize(new FileStream("Document1.xml", FileMode.Open)); foreach (var element in document.Element1) { Console.WriteLine(((TextBox)element).Name); } Console.ReadLine(); and it dosen't print anything. When I try to serialize it like so: var serializer = new XmlSerializer(typeof(Document)); var document = new Document(); document.Element1 = new List<Element>(); document.Element1.Add(new TextBox() { Name = "abc" }); serializer.Serialize(new FileStream("d.xml", FileMode.Create), document); ...the output is: <?xml version="1.0"?> <Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Element1> <Element xsi:type="TextBox"> <Element1 /> <Name>abc</Name> </Element> </Element1> </Document> When it should be: <Document> <TextBox Name="abc" /> </Document> Any ideas how to fix the xsd or another code generator? Thanks.

    Read the article

  • JAXB adding namespace to parent but not to the child elements contained

    - by Nishant
    I put together an XSD and used JAXB to generate classes out of it. Here are my XSDs- myDoc.xsd : <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns="http://www.mydoc.org" targetNamespace="http://www.mydoc.org" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mtp="http://www.mytypes.com" elementFormDefault="qualified"> <xs:import namespace="http://www.mytypes.com" schemaLocation="mytypes.xsd" /> <xs:element name="myDoc"> <xs:complexType> <xs:sequence> <xs:element name="crap" type="xs:string"/> <xs:element ref="mtp:foo"/> <xs:element ref="mtp:bar"/> </xs:sequence> </xs:complexType> </xs:element> mytypes.xsd <?xml version="1.0" encoding="UTF-8"?> <xs:schema targetNamespace="http://www.mytypes.com" xmlns="http://www.mytypes.com" xmlns:tns="http://www.mytypes.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified"> <xs:element name="foo" type="tns:Foo"/> <xs:element name="bar" type="tns:Bar"/> <xs:element name="spam" type="tns:Spam"/> <xs:simpleType name="Foo"> <xs:restriction base="xs:string"></xs:restriction> </xs:simpleType> <xs:complexType name="Bar"> <xs:sequence> <xs:element ref="spam"/> </xs:sequence> </xs:complexType> <xs:simpleType name="Spam"> <xs:restriction base="xs:string" /> </xs:simpleType> </xs:schema> The document marshalled is- <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <myDoc xmlns:ns2="http://www.mytypes.com"> <crap>real crap</crap> <ns2:foo>bleh</ns2:foo> <ns2:bar> <spam>blah</spam> </ns2:bar> </myDoc> Note that the <spam> element uses the default namespace. I would like it to use the ns2 namespace. The schema (mytypes.xsd) expresses the fact that <spam> is contained within <bar> which in the XML instance is bound to the ns2 namespace. I've broken my head over this for over a week and I would like ns2 prefix to appear in <spam>. What should I do? Required : <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <myDoc xmlns:ns2="http://www.mytypes.com"> <crap>real crap</crap> <ns2:foo>bleh</ns2:foo> <ns2:bar> <ns2:spam>blah</ns2:spam><!--NS NS NS--> </ns2:bar> </myDoc>

    Read the article

  • Convert XML namespace prefixes with C#?

    - by jrista
    I have run into an exasperating problem getting a Java service client to communicate successfully with a WCF service. I have overcome many hurdles, and I believe that this is my last one. The problem boils down to how Java Axis + WSS4J seem to handle xml namespaces. The Java platform seem to be very rigid in what they expect for xml namespace prefixes, and as such, do not understand the WCF reply messages. My problem in a nutshell is as follows. I have an xml response similar to the following from my WCF service: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <s:Header> <a:Action s:mustUnderstand="1" u:Id="_3">http://tempuri.org/IProcessor/DoProcessingResponse</a:Action> <h:CorrelationID xmlns:h="http://tempuri.org/">1234</h:CorrelationID> <a:RelatesTo u:Id="_4">uuid:40f800a0-9613-4f4a-96c5-b9fd98085deb</a:RelatesTo> <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <!-- WS-Security header stuff --> </o:Security> </s:Header> <s:Body u:Id="_1"> <e:EncryptedData Id="_2" Type="http://www.w3.org/2001/04/xmlenc#Content" xmlns:e="http://www.w3.org/2001/04/xmlenc#"> <e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/> <e:CipherData> <e:CipherValue>NfA6XunmyLlT2ucA+5QneoawHm+imcaCltDAJC1mRZOSxoB6YGpDLY1FyVykPbPGDoFGUESLsmvvbD62sNnRrgE+AuKPo+1CD3DF4LfurRcEv9A50ba9V+ViqlrhydhK</e:CipherValue> </e:CipherData> </e:EncryptedData> </s:Body> </s:Envelope> This response uses simple one-character namespace prefixes for most things, such as 's' for SOAP Envelope, 'a' for WS-Addressing, 'o' for 'WS-Security', etc. The Java client, namely WSS4J, seems to expect the following: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <soap:Header> <wsa:Action soap:mustUnderstand="1" wsu:Id="_3">http://tempuri.org/IProcessor/DoProcessingResponse</wsa:Action> <h:CorrelationID xmlns:h="http://tempuri.org/">1234</h:CorrelationID> <wsa:RelatesTo wsu:Id="_4">uuid:40f800a0-9613-4f4a-96c5-b9fd98085deb</a:RelatesTo> <wsse:Security soap:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <!-- WS-Security header stuff --> </wsse:Security> </soap:Header> <soap:Body u:Id="_1"> <xenc:EncryptedData Id="_2" Type="http://www.w3.org/2001/04/xmlenc#Content" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"> <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/> <xenc:CipherData> <xenc:CipherValue>NfA6XunmyLlT2ucA+5QneoawHm+imcaCltDAJC1mRZOSxoB6YGpDLY1FyVykPbPGDoFGUESLsmvvbD62sNnRrgE+AuKPo+1CD3DF4LfurRcEv9A50ba9V+ViqlrhydhK</xenc:CipherValue> </xenc:CipherData> </xenc:EncryptedData> </soap:Body> </soap:Envelope> Upon receipt of my response message, the Java client and WSS4J seem to want to look up elements by their own internal xml aliases, such as 'wsa' for WS-Addressing, and 'wsse' for WS-Security Extensions. Since neither of those namespaces are present in the actual response xml, exceptions are thrown. I am wondering if there is any simple way to transform an xml document from one set of namespaces to another set using C#, .NET, and the System.Xml namespace. I've poked around with XmlNamespaceManager a bit, but it does not seem to fully support what I need...or at least, I have been unable to find any really useful examples, and am not fully sure how it works. I am trying to avoid having to write some heavy-duty process to handle this manually myself, as I do not want to drastically impact the performance of our services when called by a Java Axis/WSS4J client.

    Read the article

< Previous Page | 36 37 38 39 40 41 42 43 44 45 46 47  | Next Page >