• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Java Web Services 2

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have a quesion on how did ou parse the XML i have big XML to be Parse can you tell me how to do the Parsing.I want to Extract only one values of it for example(<ns1:RouteMap description="Route Overview">) has the GIF URL i want to show the URL only. how can we get that please help on this......

for Example.

[ December 01, 2008: Message edited by: Ulf Dittmer ]
 
Prasanth Duggirala
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i tried like this but iam getting the all the gif Files

public static Source makeXsltMap()
{
String xmlText ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<xsl:stylesheet "
+ "version=\"1.0\" "
+ "xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" "
+ "xmlns:ogx=\"http://www.opengis.net/xls\" "
+ "xmlns:ogg=\"http://www.opengis.net/gml\">"
+ "<xsl:output method=\"text\" encoding=\"UTF-8\"/>"
+ "<xsl:strip-space elements=\"*\" />"
+ "<xsl:template match=\"/\">"
+ "<xsl:apply-templates select=\"ogx:XLS/ogx:Response/ogx:DetermineRouteResponse/ogx:RouteMap/ogx:Content\"/>"
+"<xsl:for-each select=\"ogx:Content\">"
+ "<xsl:if test=\"ogx:RouteMap[@description='Route Overview']\">"
+ "<xsl:value-of select=\"ogg:URL\"/>"
+ "</xsl:if>"
+"</xsl:for-each>"
+ "</xsl:template>"
+ "</xsl:stylesheet>";
return xmlStringToSource(xmlText);
}
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseAMeaningfulSubjectLine

Use XPath

Example
Another Example
[ December 01, 2008: Message edited by: Peer Reynders ]
 
Prasanth Duggirala
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Can we pass parameters to a web method in URL what we created for example in .NET it is possible.

the webservice i created url is http://10.232.25.136:8080/deCartaProj/wsdl/GeoCode.wsdl can we pass parameters to the web method in the URL

this is the content of WSDL

<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions targetNamespace="http://java.deCarta.com" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://java.deCarta.com" xmlns:intf="http://java.deCarta.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <!--
WSDL created by Apache Axis version: 1.2.1
Built on Jun 14, 2005 (09:15:57 EDT)

-->
- <wsdl:types>
- <schema elementFormDefault="qualified" targetNamespace="http://java.deCarta.com" xmlns="http://www.w3.org/2001/XMLSchema">
- <element name="getGeoCode">
- <complexType>
- <sequence>
<element name="Countrycode" type="xsd:string" />
<element name="Street" type="xsd:string" />
<element name="BuildingNo" type="xsd:string" />
<element name="Pincode" type="xsd:string" />
</sequence>
</complexType>
</element>
- <element name="getGeoCodeResponse">
- <complexType>
- <sequence>
<element name="getGeoCodeReturn" type="xsd:string" />
</sequence>
</complexType>
</element>
</schema>
</wsdl:types>
- <wsdl:message name="getGeoCodeResponse">
<wsdl:part element="impl:getGeoCodeResponse" name="parameters" />
</wsdl:message>
- <wsdl:message name="getGeoCodeRequest">
<wsdl:part element="impl:getGeoCode" name="parameters" />
</wsdl:message>
- <wsdl:portType name="GeoCode">
- <wsdl:operation name="getGeoCode">
<wsdl:input message="impl:getGeoCodeRequest" name="getGeoCodeRequest" />
<wsdl:output message="impl:getGeoCodeResponse" name="getGeoCodeResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="GeoCodeSoapBinding" type="impl:GeoCode">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="getGeoCode">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="getGeoCodeRequest">
<wsdlsoap:body use="literal" />
</wsdl:input>
- <wsdl:output name="getGeoCodeResponse">
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="GeoCodeService">
- <wsdl:port binding="impl:GeoCodeSoapBinding" name="GeoCode">
<wsdlsoap:address location="http://10.232.25.136:8080/deCartaProj/services/GeoCode" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

please help me on this
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by prasanth duggirala:
Hi Can we pass parameters to a web method in URL what we created
for example in .NET it is possible.



That is not standard behavior for web services with a SOAP binding.

You have seen a feature of Visual Studio deploying an ASP.NET web service to a development IIS server.
browser pages for web services tests
Some other IDEs may have adopted this - though strictly as a development feature. This mode of operation has nothing to do with SOAP web services (and nothing with RESTful HTTP web services either). It is simply a degenerate RPC mechanism through an HTTP GET.
[ December 01, 2008: Message edited by: Peer Reynders ]
 
Prasanth Duggirala
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okie thanks Peer
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Again

  • this has nothing to do with SOAP
  • this WSDL feature is not widely supported by WSDL-to-code generators


  • But WSDL 1.1 does support HTTP bindings for HTTP GET and POST (either or, not both)

    it would look something like this:


    4. HTTP GET & POST Binding
    Using the HTTP Binding Component with the HTTP GET method
    Using the HTTP Binding Component with the HTTP POST method
     
    Prasanth Duggirala
    Ranch Hand
    Posts: 36
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Peer i got the answer for getting the URL of the Route Overview i asked you

    protected static Source makeXsltMap()
    {
    String xmlText ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    + "<xsl:stylesheet "
    + "version=\"1.0\" "
    + "xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" "
    + "xmlns:ogx=\"http://www.opengis.net/xls\" "
    + "xmlns:ogg=\"http://www.opengis.net/gml\">"
    + "<xsl:output method=\"text\" encoding=\"UTF-8\"/>"
    + "<xsl:strip-space elements=\"*\" />"
    + "<xsl:template match=\"/\">"
    + "<xsl:apply-templates select=\"ogx:XLS/ogx:Response/ogx:DetermineRouteResponse/ogx:RouteMap[@description='Route Overview']/ogx:Content/ogx:URL\"/>"
    + "</xsl:template>"
    + "</xsl:stylesheet>";
    return xmlStringToSource(xmlText);
    }

    Now i Had anew xml which i want to show the attribute values for xml shown below
    --
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <ns1:XLS ns1:lang="en" rel="4.3.2" version="1" xmlns:ns1="http://www.opengis.net/xls">
    <ns1:ResponseHeader sessionID="999"/>
    <ns1:Response numberOfResponses="1" requestID="10" version="1.0">
    <ns1:DirectoryResponse>
    <ns1:POIContext>
    <ns1:POI phoneNumber="+(1)-(201)-8368222" POIName="ATRIUM CAFE" ID="0">
    <ns1:POIAttributeList>
    <ns1:POIInfoList>
    <ns1:POIInfo value="400" name="ADDRESS INFO"/>
    <ns1:POIInfo value="37295075" name="ID"/>
    </ns1:POIInfoList>
    </ns1:POIAttributeList>
    <ns2:Point xmlns:ns2="http://www.opengis.net/gml">
    <ns2:pos>40.873885 -74.00668</ns2:pos>
    </ns2:Point>
    <ns1:Address countryCode="US">
    <ns1:StreetAddress>
    <ns1:Building number="392"/>
    <ns1:Street>FRANK W BURR BLVD</ns1:Street>
    </ns1:StreetAddress>
    <ns1:Place type="CountrySubdivision">NJ</ns1:Place>
    <ns1:Place type="CountrySecondarySubdivision">BERGEN</ns1:Place>
    <ns1:Place type="Municipality">TEANECK TWP</ns1:Place>
    <ns1:Place type="MunicipalitySubdivision">TEANECK</ns1:Place>
    <ns1:PostalCode>07666</ns1:PostalCode>
    </ns1:Address>
    </ns1:POI>
    <ns1:Distance uom="M" value="51.26"/>
    </ns1:POIContext>
    <ns1:POIContext>
    <ns1:POI phoneNumber="+(1)-(201)-8360600" POIName="THE GRILL" ID="0">
    <ns1:POIAttributeList>
    <ns1:POIInfoList>
    <ns1:POIInfo value="100" name="ADDRESS INFO"/>
    <ns1:POIInfo value="37347368" name="ID"/>
    </ns1:POIInfoList>
    </ns1:POIAttributeList>
    <ns3:Point xmlns:ns3="http://www.opengis.net/gml">
    <ns3:pos>40.872715 -74.006925</ns3:pos>
    </ns3:Point>
    <ns1:Address countryCode="US">
    <ns1:StreetAddress>
    <ns1:Building number="150"/>
    <ns1:Street>FRANK W BURR BLVD</ns1:Street>
    </ns1:StreetAddress>
    <ns1:Place type="CountrySubdivision">NJ</ns1:Place>
    <ns1:Place type="CountrySecondarySubdivision">BERGEN</ns1:Place>
    <ns1:Place type="Municipality">TEANECK TWP</ns1:Place>
    <ns1:Place type="MunicipalitySubdivision">TEANECK</ns1:Place>
    <ns1:PostalCode>07666</ns1:PostalCode>
    </ns1:Address>
    </ns1:POI>
    <ns1:Distance uom="M" value="181.79"/>
    </ns1:POIContext>
    <ns1:POIContext>
    <ns1:POI phoneNumber="+(1)-(201)-8361597" POIName="DAIRY QUEEN" ID="0" description="DAIRY QUEEN">
    <ns1:POIAttributeList>
    <ns1:POIInfoList>
    <ns1:POIInfo value="260" name="ADDRESS INFO"/>
    <ns1:POIInfo value="17007333" name="ID"/>
    </ns1:POIInfoList>
    </ns1:POIAttributeList>
    <ns4:Point xmlns:ns4="http://www.opengis.net/gml">
    <ns4:pos>40.871355 -74.01354</ns4:pos>
    </ns4:Point>
    <ns1:Address countryCode="US">
    <ns1:StreetAddress>
    <ns1:Building number="290"/>
    <ns1:Street>TEANECK RD/CR-39</ns1:Street>
    </ns1:StreetAddress>
    <ns1:Place type="CountrySubdivision">NJ</ns1:Place>
    <ns1:Place type="CountrySecondarySubdivision">BERGEN</ns1:Place>
    <ns1:Place type="Municipality">TEANECK TWP</ns1:Place>
    <ns1:Place type="MunicipalitySubdivision">TEANECK</ns1:Place>
    <ns1:PostalCode>07666</ns1:PostalCode>
    </ns1:Address>
    </ns1:POI>
    <ns1:Distance uom="M" value="680.54"/>
    </ns1:POIContext>
    </ns1:DirectoryResponse>
    </ns1:Response>
    </ns1:XLS>
    --
    In POI Element iam reciving "Phonenumber" and "POIName" this attributes have values i want to show only the attribute values can you help me on this. thanking you
     
    Greenhorn
    Posts: 4
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Prasant,
    Why don't you use DOM parser for this task.Its comaparitively easier to use than what you are trying to do.

    For example,i am pasting a piece fo code and XML from which i am reading contents from userid and password tags.

    All you need to do is adding a DOM jar and start using the methods

    ------------------------------------------------------------------------
    XML
    --------------------------------------------------------------------------
    <?xml version="1.0" encoding="UTF-8"?>
    <userdetails>

    <users>
    <recordNum>1</recordNum>
    <userID>ukx1100</userID>
    <passWord>nissan</passWord>
    <firstname>Praveen</firstname>
    <lastname>Ayitha</lastname>
    <emailID>[email protected]</emailID>
    </users>

    <users>
    <recordNum>2</recordNum>
    <userID>UKX1416</userID>
    <passWord>Nnissan08</passWord>
    <firstname>Edith</firstname>
    <lastname>Paul</lastname>
    <emailID>[email protected]</emailID>
    </users>




    </userdetails>
    --------------------------------------------------------------------------
    Code
    --------------------------------------------------------------------------
    File loginxml=new File(c:\login.xml);
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    Document doc = db.parse(loginxml);
    doc.getDocumentElement().normalize();
    logger.debug("====Root element " + doc.getDocumentElement().getNodeName());
    NodeList nodeLst = doc.getElementsByTagName("users");
    logger.debug("Information of all users");
    for (int s = 0; s < nodeLst.getLength(); s++) {

    Node fstNode = nodeLst.item(s);

    if (fstNode.getNodeType() == Node.ELEMENT_NODE) {

    Element fstElmnt = (Element) fstNode;
    NodeList fstNmElmntLst = fstElmnt.getElementsByTagName("userID");
    Element fstNmElmnt = (Element) fstNmElmntLst.item(0);
    NodeList fstNm = fstNmElmnt.getChildNodes();
    logger.debug("User ID : " + ((Node) fstNm.item(0)).getNodeValue());
    String userID=((Node) fstNm.item(0)).getNodeValue();
    NodeList lstNmElmntLst = fstElmnt.getElementsByTagName("passWord");
    Element lstNmElmnt = (Element) lstNmElmntLst.item(0);
    NodeList lstNm = lstNmElmnt.getChildNodes();
    logger.debug("passWord : " + ((Node) lstNm.item(0)).getNodeValue());
    String userPwd=((Node) lstNm.item(0)).getNodeValue();
     
    Peer Reynders
    Bartender
    Posts: 2968
    6
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by prasanth duggirala:
    i got the answer for getting the URL of the Route Overview ...

    Now i Had anew xml which i want to show the attribute values for xml shown below
    ...

    In POI Element iam reciving "Phonenumber" and "POIName" this attributes have values i want to show only the attribute values can you help me on this.




    As I pointed out in an earlier post XSLT is not the right tool for this job - XPath is!

    Two simple XPath expressions get you on your way:

    Route Overview GIF Image URL


    Points Of Interest





    [ December 10, 2008: Message edited by: Peer Reynders ]
     
    Prasanth Duggirala
    Ranch Hand
    Posts: 36
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Peer and Priya,

    thanks for you helping me in this issue.

    Thanks and Regards,
    Prasanth Duggirala
    Chennai CTS.
     
    Greenhorn
    Posts: 3
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hello,

    I am quite new to this forum but it surprises me that noone talks about xml-data binding. If you have such big xml and change prone requirements I believe its best to use put a data binding mecahnism like Castor or JIBX (I am a real fan). Though if you wish to get only one or two fields from the xml then DOM parser comes first to the mind, yet if you are getting this big an xml then there must be some reason, I guess. If you are going to use it one way or other then why not bind it to a java bean and perform your operations on that.

    And I can be grossly incorrect
    [ December 11, 2008: Message edited by: Ulf Dittmer ]
     
    Prasanth Duggirala
    Ranch Hand
    Posts: 36
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Gautam,

    Thanks you for your support.

    Can you provide me any example on that so i can work on it.

    Take a XML as a example of what i provided earlier.
     
    Peer Reynders
    Bartender
    Posts: 2968
    6
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Gautam Tiwari:
    If you have such big xml and change prone requirements I believe its best to use put a data binding mecahnism like Castor or JIBX (I am a real fan).



    You didn't mention JAXB which is now included in Java SE 6 and can be easily added to Java SE 5. JiBX is really the only choice when you need to bind an existing schema to an existing object model (the others tend to generate one from the other) which you then have to manually map. The primary use case for these XML binding frameworks is when you bind an entire XML document to an object model - i.e. you need access to all aspects of the XML document.

    Also I have to disagree that XML binding is suited to situations where the underlying XML Schema of the XML document is prone to change. Binding frameworks bind according to the entire schema, so when the schema changes the binding breaks and has to be regenerated. Now if you require complete (bi-directional) binding, then a binding framework will speed up the process of reacting to change when compared to hand-coded (un)marshalling logic.

    In this case we are only interested in one or two isolated items in a much larger XML document. An XPath expression can quickly acquire these; furthermore there are many smaller changes that can be made to the underlying schema of the XML document that will not invalidate the XPath expression.So because the XPath expression lets us focus on only the portion of the XML document that we are interested in, rather that the entire XML document (as a binding framework would do) the XPath expression is actually more resilient in the face of change.
     
    Gautam Tiwari
    Greenhorn
    Posts: 3
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Peer Reynders:


    You didn't mention JAXB which is now included in Java SE 6 and can be easily added to Java SE 5. JiBX is really the only choice when you need to bind an existing schema to an existing object model (the others tend to generate one from the other) which you then have to manually map. The primary use case for these XML binding frameworks is when you bind an entire XML document to an object model - i.e. you need access to all aspects of the XML document.

    Also I have to disagree that XML binding is suited to situations where the underlying XML Schema of the XML document is prone to change. Binding frameworks bind according to the entire schema, so when the schema changes the binding breaks and has to be regenerated. Now if you require complete (bi-directional) binding, then a binding framework will speed up the process of reacting to change when compared to hand-coded (un)marshalling logic.

    In this case we are only interested in one or two isolated items in a much larger XML document. An XPath expression can quickly acquire these; furthermore there are many smaller changes that can be made to the underlying schema of the XML document that will not invalidate the XPath expression.So because the XPath expression lets us focus on only the portion of the XML document that we are interested in, rather that the entire XML document (as a binding framework would do) the XPath expression is actually more resilient in the face of change.



    Thanks Peers,
    I really accept what you said. Certainly if the entire req is to get a few fields, we should go ahead and use XPATH even DOM parser will do. No doubts about that.
    Regarding binding, just wanna share a good thing about JIBX that it really makes life easy when the underlying schema does not change much, though certainly you will have to make a few minor adjustments, but thats inevitable...
    Have fun...
     
    Prasanth Duggirala
    Ranch Hand
    Posts: 36
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Can any one answer all this questions please.

    Please find questions in attached file.
    Quessions.JPG
    [Thumbnail for Quessions.JPG]
    Questions
     
    You've gotta fight it! Don't give in! Read this tiny ad:
    Smokeless wood heat with a rocket mass heater
    https://woodheat.net
    reply
      Bookmark Topic Watch Topic
    • New Topic