DocNote 376987.1 getContentAsString vs get-content-as-string: is this fix ?

I've hit a problem with orcl:get-content-as-string() (BPEL 10.1.2), which looks like it's already been identified. When multiple namespace are passed within a tag I get 'import not allowed on nodes of type element declaration'
metalink search finds a technote (relevent text quoted below) but I can't find an actual bug report. Is the suggested use of ora:getContentAsString instead of orcl:get-content-as-string the only permanent solution? Are there any issues to be aware of when swicthing to ora:getContentAsString ?
Regards
Rob
From Doc Note 376987.1:
"The function "get-content-as-string()" might also throw the following error when the xml tags contains namespace declarations.
"import not allowed on nodes of type element declaration"
To workaround the error us the function "ora:getContentAsString()" instead
The function "ora:getContentAsString()" has therefore always to be used in favor of the function "orcl:get-content-as-string()"

use always: ora:getContentAsString()
Reakted bug to this issue are bug 5103822 en 4283492

Similar Messages

  • Get HTML page content as string in BPEL

    Hi!
    I would like to get HTML page content as string in BPEL via partnerLink.
    So, I define WSDL file for this partnerLink:
    <definitions targetNamespace="urn:GetSummaryContent"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="urn:GetSummaryContent"
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
    xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:http="http://schemas.xmlsoap.org/wsdl/http/">
    <message name="MarkMessageAsReadHttpGetIn">
    <part name="webid" type="xsd:string"/>
    </message>
    <message name="MarkMessageAsReadHttpGetOut">
    <part name="Body" type="xsd:anyType"/>
    </message>
    <portType name="getHtmlPageGet">
    <operation name="getHtmlPage">
    <input message="tns:MarkMessageAsReadHttpGetIn"/>
    <output message="tns:MarkMessageAsReadHttpGetOut"/>
    </operation>
    </portType>
    <binding name="MessagingHttpGet" type="tns:getHtmlPageGet">
    <http:binding verb="GET"/>
    <operation name="getHtmlPage">
    <http:operation location=""/>
    <input>
    <http:urlEncoded/>
    </input>
    <output>
    <mime:content type="text/html" part="Body"/>
    </output>
    </operation>
    </binding>
    <service name="Messaging">
    <port name="MessagingHttpGet" binding="tns:MessagingHttpGet">
    <http:address location="http://server:port/app-context-root/sss.xsql"/>
    </port>
    </service>
    </definitions>
    As a result I got bindingFault: [email protected]9b : Could not find binding output for operation getHtmlPage
    Could You help me to solve this trouble?
    Have You any solution?
    Thank You.

    What are you trying to accomplish?

  • How to get an XML string from a Java Bean without wrting to a file first ?

    I know we can save a Java Bean to an XML file with XMLEncoder and then read it back with XMLDecoder.
    But how can I get an XML string of a Java Bean without writing to a file first ?
    For instance :
    My_Class A_Class = new My_Class("a",1,2,"Z", ...);
    String XML_String_Of_The_Class = an XML representation of A_Class ?
    Of course I can save it to a file with XMLEncoder, and read it in using XMLDecoder, then delete the file, I wonder if it is possible to skip all that and get the XML string directly ?
    Frank

    I think so too, but I am trying to send the object to a servlet as shown below, since I don't know how to send an object to a servlet, I can only turn it into a string and reconstruct it back to an object on the server side after receiving it :
    import java.io.*;
    import java.net.*;
    import java.util.*;
    class Servlet_Message        // Send a message to an HTTP servlet. The protocol is a GET or POST request with a URLEncoded string holding the arguments sent as name=value pairs.
      public static int GET=0;
      public static int POST=1;
      private URL servlet;
      // the URL of the servlet to send messages to
      public Servlet_Message(URL servlet) { this.servlet=servlet; }
      public String sendMessage(Properties args) throws IOException { return sendMessage(args,POST); }
      // Send the request. Return the input stream with the response if the request succeeds.
      // @param args the arguments to send to the servlet
      // @param method GET or POST
      // @exception IOException if error sending request
      // @return the response from the servlet to this message
      public String sendMessage(Properties args,int method) throws IOException
        String Input_Line;
        StringBuffer Result_Buf=new StringBuffer();
        // Set this up any way you want -- POST can be used for all calls, but request headers
        // cannot be set in JDK 1.0.2 so the query string still must be used to pass arguments.
        if (method==GET)
          URL url=new URL(servlet.toExternalForm()+"?"+toEncodedString(args));
          BufferedReader in=new BufferedReader(new InputStreamReader(url.openStream()));
          while ((Input_Line=in.readLine()) != null) Result_Buf.append(Input_Line+"\n");
        else     
          URLConnection conn=servlet.openConnection();
          conn.setDoInput(true);
          conn.setDoOutput(true);           
          conn.setUseCaches(false);
          // Work around a Netscape bug
          conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
          // POST the request data (html form encoded)
          DataOutputStream out=new DataOutputStream(conn.getOutputStream());
          if (args!=null && args.size()>0)
            out.writeBytes(toEncodedString(args));
    //        System.out.println("ServletMessage args: "+args);
    //        System.out.println("ServletMessage toEncString args: "+toEncodedString(args));     
          BufferedReader in=new BufferedReader(new InputStreamReader(conn.getInputStream()));
          while ((Input_Line=in.readLine()) != null) Result_Buf.append(Input_Line+"\n");
          out.flush();
          out.close(); // ESSENTIAL for this to work!          
        return Result_Buf.toString();               // Read the POST response data   
      // Encode the arguments in the property set as a URL-encoded string. Multiple name=value pairs are separated by ampersands.
      // @return the URLEncoded string with name=value pairs
      public String toEncodedString(Properties args)
        StringBuffer sb=new StringBuffer();
        if (args!=null)
          String sep="";
          Enumeration names=args.propertyNames();
          while (names.hasMoreElements())
            String name=(String)names.nextElement();
            try { sb.append(sep+URLEncoder.encode(name,"UTF-8")+"="+URLEncoder.encode(args.getProperty(name),"UTF-8")); }
    //        try { sb.append(sep+URLEncoder.encode(name,"UTF-16")+"="+URLEncoder.encode(args.getProperty(name),"UTF-16")); }
            catch (UnsupportedEncodingException e) { System.out.println(e); }
            sep="&";
        return sb.toString();
    }As shown above the servlet need to encode a string.
    Now my question becomes :
    <1> Is it possible to send an object to a servlet, if so how ? And at the receiving end how to get it back to an object ?
    <2> If it can't be done, how can I be sure to encode the string in the right format to send it over to the servlet ?
    Frank

  • Can't get content from PCD

    Hi,
    I've developed a small project to read content from pcd, in this case, to get roles attributes. I've followed this tutorial http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/6112ecb7-0a01-0010-ef90-941c70c9e401?QuickLink=index&overridelayout=true, but I keep getting a NoClassDefFound for IPCDContext and PCDSearchConrols(if i choose to use this objet instead). I've added a DC of the External Library type to my project wich contained all the jars needed. Here's the code for my project:
    import java.util.Hashtable;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingEnumeration;
    import javax.naming.NamingException;
    import javax.naming.directory.DirContext;
    import java.lang.Object;
    import com.sap.portal.directory.Constants;
    import com.sap.portal.pcm.admin.PcmConstants;
    import com.sap.security.api.IRole;
    import com.sap.security.api.IUser;
    import com.sap.tc.webdynpro.services.sal.um.api.WDClientUser;
    import com.sap.tc.webdynpro.services.sal.um.api.WDUMException;
    import com.sap.teste.wdp.IPrivateShowRoleView;
    import com.sapportals.portal.pcd.gl.IPcdContext;
    import com.sapportals.portal.pcd.pcm.roles.IPortalRole;
    import com.sapportals.portal.pcd.gl.IPcdAttribute;
    import com.sapportals.portal.pcd.gl.IPcdContext;
    import com.sapportals.portal.pcd.gl.IPcdSearchResult;
    import com.sapportals.portal.pcd.gl.PcdSearchControls;
    import com.sap.portal.pcm.admin.IAdminBase;
    import com.sap.portal.pcm.admin.IAttributeSet;
    import com.sap.portal.pcm.admin.ValidationException;
    import com.sap.tc.webdynpro.progmodel.api.WDValueServices;
    import com.sap.tc.webdynpro.progmodel.api.WDVisibility;
    import com.sap.tc.webdynpro.services.sal.datatransport.api.IWDResource;
    import com.sapportals.portal.prt.component.IPortalComponentRequest;
    import com.sapportals.portal.pcd.gl.IPcdSearchResult;
      public void wdDoInit()
       IUser user = null;
        try{
             user = WDClientUser.getCurrentUser().getSAPUser();
        catch(WDUMException e){
             wdContext.currentContextElement().setResult(e.getMessage());
             Hashtable env = new Hashtable();     
         env.put(IPcdContext.SECURITY_PRINCIPAL, user);
         env.put(Context.INITIAL_CONTEXT_FACTORY, IPcdContext.PCD_INITIAL_CONTEXT_FACTORY);
         env.put(Constants.REQUESTED_ASPECT,   IPcdAttribute.PERSISTENCY_ASPECT);     
         InitialContext iCtx = null;
         try
              String iRoleDir = "pcd:portal_content/mmmarques/role_teste3";
              iCtx = new InitialContext(env);
              IPcdContext attrSet = (IPcdContext) iCtx.lookup(iRoleDir);
              attrSet.getAttributes("").get("com.sap.portal.pcd.gl.CreatedAt").get().toString();
              attrSet.getAttributes("").get("com.sap.portal.pcd.gl.LastChangedBy").get().toString();
              attrSet.getAttributes("").get("com.sap.portal.pcd.gl.LastChangedAt").get().toString();
              attrSet.getAttributes("").get("com.sap.portal.pcm.Title").get().toString();
         catch (Exception e) {
              wdContext.currentContextElement().setResult("failed");
    If anybody could help, I would be very grateful. Thanks in advance

    Also, when I try to build my external library DC I get the following warnings:
    createPublicParts:
      [pppacker] Packing public part 'ExternalLibs'
      [pppacker] Packed   1 file  for entity activation.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity bc.rf.framework_api.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity bc.rf.global.service.mime_api.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity bc.rf.global.service.pipeline_api.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity bc.rf.global.service.urlgenerator_api.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity bc.sf.framework_api.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity bc.util.public_api.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity com.sap.portal.navigation.api_service_api.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity com.sap.portal.navigation.helperservice_api.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity com.sap.portal.navigation.service_api.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity com.sap.portal.pcd.roleservice_api.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity com.sap.portal.themes.lafservice_api.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity com.sap.portal.usermanagementapi.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity com.sap.security.api.ep5.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity com.sap.security.api.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity gl_api.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity km.shared.command_api.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity km.shared.repository.service.accessstatistic_api.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity km.shared.repository.service.app.subscription_api.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity km.shared.repository.service.timebasedpublish_api.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity km.shared.service.actioninbox_api.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity km.shared.ui.util_api.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity mail.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity ojdbc14.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity poi-3.0-rc4-20070503.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity poi-contrib-3.0-rc4-20070503.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity poi-scratchpad-3.0-rc4-20070503.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity prtapi.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity prtconnection.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity prtjndisupport.jar (Archive/Java Library)
      [pppacker] Packed   1 file  for entity tcepbcpcmadminapijava.jar (Archive/Java Library)
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\com.sap.portal.usermanagementapi.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\km.shared.repository.service.timebasedpublish_api.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\bc.rf.global.service.mime_api.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\prtconnection.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\bc.rf.framework_api.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\gl_api.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\poi-3.0-rc4-20070503.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\prtapi.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\bc.util.public_api.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\com.sap.portal.navigation.service_api.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\com.sap.portal.navigation.helperservice_api.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\activation.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\bc.sf.framework_api.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\com.sap.portal.themes.lafservice_api.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\com.sap.portal.pcd.roleservice_api.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\com.sap.security.api.ep5.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\com.sap.security.api.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\tcepbcpcmadminapijava.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\prtjndisupport.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\km.shared.command_api.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\km.shared.ui.util_api.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\poi-contrib-3.0-rc4-20070503.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\bc.rf.global.service.pipeline_api.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\km.shared.service.actioninbox_api.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\km.shared.repository.service.app.subscription_api.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\bc.rf.global.service.urlgenerator_api.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\com.sap.portal.navigation.api_service_api.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\km.shared.repository.service.accessstatistic_api.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\ojdbc14.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\mail.jar
      [pppacker] WARNING: Can not overwrite file C:\Users\mmmarques\.dtc\1\DCs\sonae.com\ag360\jars_dc2\_comp\gen\default\public\ExternalLibs\lib\java\poi-scratchpad-3.0-rc4-20070503.jar
      [pppacker] Packed 31 entities for public part 'ExternalLibs'
         [timer] Packing of public part 'ExternalLibs' finished in 0.047 seconds
    Edited by: babonhas8 on Jul 22, 2011 11:16 AM

  • How to get an xml string into a Document w/o escaping mark-up characters?

    Hi,
    I am using one of the latest xerces using Java. I am pretty sure I am using xerces-2.
    I have an existing Document and I am trying to add more content to it. The new content itself is xml string. I am trying to insert this xml string into the document using document.createTextNode. I am able to insert, but somewhere it is escaping the mark-up characters (<,>,etc). When I convert the document into String, I can see, for example, <userData> instead of <userData>.
    There is an alternative option to accomplish this by creating a new document with this xml string, get the root element, import this element into my document. Execution time for this procedure is very high - means, this is very bad in terms of time-wise performance.
    Can any help on how to accomplish this (bringing an xml string into a document without escaping mark-up characters) in time-efficient way.

    So you want to treat the contents of the string as XML rather than as text? Then you have to parse it.
    Or if your reason for asking is just that you don't like the look of escaped text, then use a CDATA section to contain the text.

  • Get content of web page in java. Result - bad chars.

    My common task is - get content of page in java. And parse data on this page.
    When i am opening page in browser - i have a good look of all data. But when i am using java code for getting page content i have a bad content with bad chars.
    How to do it right?
    Thanx in advance!
    public static void main(String[] args) {
                 String url_get_page = "http://www.pai.pt/search.ds?activeSort=name+-maindocflag|asc&distSort=false&encodedRefinement=namechar1..%3d..^A%24..%26..A&what=Advogados&startingPageNumber=1&stageName=What+search&originalOffset=1&expandWWWSearch=false&myplaces=false&distance=50&searchType=www&phoneNumberSearch=false&advancedSearch=true&alphaRefineable=AN4683|BN317|CN2373|DN696|EN704|FN1549|GN456|HN539|IN670|JN3704|KN8|LN1433|MN4143|NN606|ON318|PN1727|QN9|RN1383|SN1522|TN484|UN14|VN677|WN16|XN8|YN4|ZN23|[0-9]N0&excludeZone=false&restoSearch=false&firstMaxRank=43522&previousPath=search";
                 StringBuffer result = new StringBuffer();
                 URL url;
              try {
                      url = new URL(url_get_page);               
                         HttpURLConnection connection = null;
                             connection = (HttpURLConnection) url.openConnection();                       
                     connection.setRequestMethod("GET");
                     connection.setDoOutput(true);
                        connection.setReadTimeout(10000);           
                        connection.setRequestProperty("Host", "www.pai.pt");
                        connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6");
                    connection.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
                    connection.setRequestProperty("Accept-Language", "ru,en-us;q=0.7,en;q=0.3");
                    connection.setRequestProperty("Accept-Encoding", "gzip,deflate");
                    connection.setRequestProperty("Accept-Charset", "windows-1251,utf-8;q=0.7,*;q=0.7");
                    connection.setRequestProperty("Keep-Alive", "115");
                    connection.setRequestProperty("Connection", "keep-alive");
                    connection.setRequestProperty("Referer", "http://www.pai.pt/search.ds");
                     connection.setRequestProperty("Cookie", "MfPers=12678646695048a98819027298bf50127329f8c315e8f; vuid=8a98819027298bf50127329f8c315e8f; ptkn=40EAFA18-5758-F374-F570-A0480F306222; WT_FPC=id=174.142.104.57-1456441520.30063880:lv=1267888167073:ss=1267888167073; __utma=76091412.2059393411.1267864686.1267878351.1267891770.4; __utmz=76091412.1267864686.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); BFHost=wd-web04.osl.basefarm.net; JSESSIONID=20C8FD4414F50F3AE361C487D0E3C719; MfTrack=12678917654148a98819027298bf50127329f8c315e8f; BIGipServerwd-web-pt=285284362.20480.0000; __utmb=76091412.1.10.1267891770; __utmc=76091412");           
                     connection.connect();
                     BufferedReader rd = new BufferedReader(new InputStreamReader(connection.getInputStream(),"UTF8"));
                     String line;
                     while ((line = rd.readLine()) != null) {
                         result.append(line).append("\n");
                     connection.disconnect();
                   } catch (MalformedURLException e) {
                        e.printStackTrace();
                   } catch (IOException e) {
                        e.printStackTrace();
                System.out.println(result.toString());            
         }

    Now the code is
    public static void main(String[] args) {
                 String url_get_page = "http://www.pai.pt/search.ds?activeSort=name+-maindocflag|asc&distSort=false&encodedRefinement=namechar1..%3d..^A%24..%26..A&what=Advogados&startingPageNumber=1&stageName=What+search&originalOffset=1&expandWWWSearch=false&myplaces=false&distance=50&searchType=www&phoneNumberSearch=false&advancedSearch=true&alphaRefineable=AN4683|BN317|CN2373|DN696|EN704|FN1549|GN456|HN539|IN670|JN3704|KN8|LN1433|MN4143|NN606|ON318|PN1727|QN9|RN1383|SN1522|TN484|UN14|VN677|WN16|XN8|YN4|ZN23|[0-9]N0&excludeZone=false&restoSearch=false&firstMaxRank=43522&previousPath=search";
                 StringBuffer result = new StringBuffer();
                 URL url;
              try {
                      url = new URL(url_get_page);               
                     HttpURLConnection connection = null;
                    connection = (HttpURLConnection) url.openConnection();                       
                     connection.setRequestMethod("GET");
                     connection.setDoOutput(true);
                    connection.setReadTimeout(10000);           
                    connection.setRequestProperty("Host", "www.pai.pt");
                    connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6");
                    connection.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
                    connection.setRequestProperty("Accept-Language", "ru,en-us;q=0.7,en;q=0.3");
                    connection.setRequestProperty("Accept-Encoding", "gzip,deflate");
                    //connection.setRequestProperty("Accept-Charset", "windows-1251,utf-8;q=0.7,*;q=0.7");
                    connection.setRequestProperty("Keep-Alive", "115");
                    connection.setRequestProperty("Connection", "keep-alive");
                    connection.setRequestProperty("Referer", "http://www.pai.pt/search.ds");
                     connection.setRequestProperty("Cookie", "MfPers=12678646695048a98819027298bf50127329f8c315e8f; vuid=8a98819027298bf50127329f8c315e8f; ptkn=40EAFA18-5758-F374-F570-A0480F306222; WT_FPC=id=174.142.104.57-1456441520.30063880:lv=1267888167073:ss=1267888167073; __utma=76091412.2059393411.1267864686.1267878351.1267891770.4; __utmz=76091412.1267864686.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); BFHost=wd-web04.osl.basefarm.net; JSESSIONID=20C8FD4414F50F3AE361C487D0E3C719; MfTrack=12678917654148a98819027298bf50127329f8c315e8f; BIGipServerwd-web-pt=285284362.20480.0000; __utmb=76091412.1.10.1267891770; __utmc=76091412");           
                     connection.connect();
                     BufferedReader rd = new BufferedReader(new InputStreamReader(connection.getInputStream(),"UTF8"));
                     String line;
                     while ((line = rd.readLine()) != null) {
                         result.append(line).append("\n");
                     connection.disconnect();
                   } catch (MalformedURLException e) {
                        e.printStackTrace();
                   } catch (IOException e) {
                        e.printStackTrace();
                System.out.println(result.toString());            
         }I have checked in FF encoding of page is - UTF8.
    The problem still exists.

  • Remove first 30 characters from get-content

    hello
    i have a one liner which reads a file and filter it based on my criteria. the output is very lengthy. i need to remove the first 35 characters of that in order to have a clear result with no unwanted information
    Get-Content D:\netlogon.bak | Select-String -Pattern "CHI-*"
    after I filter based on pattern, i want to remove the first 35 charaters. how can i do this?
    thank you

    Get-ContentD:\netlogon.bak
    | Select-String
    -Pattern
    "CHI-*" | %{$_.SubString(35,$_.Length-35)}
    \_(ツ)_/

  • Why is Get-Content inserting extra subdirectories in directory path

    Can someone please look at the following 6 lines of code and explain the output I'm receiving?  I've been looking at the code segment for a week trying to figure out what could possibly be wrong and I can't.  At this point I'm convinced it's a
    weird powershell bug - but I'd be happy if someone here could prove me wrong, explain what I'm seeing and tell me how to correct it.  "logit" is irrelevant to the issue - it's just a simple function which calls tee-object to print the line to
    the screen and write it to a file.  I added the here string code just to inspect what the line looks like after substitution.  The value of $servertype when this code snippet runs is "Core" (as you can see in the output).
    > echo "Substituting data into C:Temp\Setup-$servertype\updates\Media\travel\con.html" | logit
    > $here = @"
    > inputfile =  get-content "C:Temp\Setup-$servertype\updates\Media\travel\con.html"
    > "@
    > $inputfile = get-content "C:Temp\Setup-$servertype\updates\Media\travel\con.html"
    > echo "The here string is: $here" | logit
    Here is the output from the above code...
    2015-01-28T13:54:05 - jim -  - Substituting data into C:Temp\Setup-CORE\updates\Media\travel\con.html
    get-content : Cannot find path 'C:\Temp\Setup-Core\Temp\Setup-CORE\updates\Medi
    a\travel\con.html' because it does not exist.
    2015-01-28T13:54:05 - jim -  - The here string is: inputfile =  get-content "C:Temp\Setup-CORE\updates\Media\travel\con.html"
    I deleted the extra error info from the above output to illustrate the problem more clearly (I'll paste it below).  The problem is that the path that cannot be found has the first 2 directory levels duplicated (C:\Temp\Setup-Core\Temp\Setup-CORE\...)
    instead of (C:\Temp\Setup-CORE\...) - note the difference in the case of the word "Core". 
    How and why could this be happening - and what do I need to do to make this work properly?
    Thanks in advance to anybody who takes the time to reply.  Here are the missing lines from the output above (I'm pretty sure it's not relevant):
    At C:\temp\setup-CORE\scripts\travel.ps1:196 char:14
    + $inputfile = get-content
    "C:Temp\Setup-$servertype\updates\Media\travel\co ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ~~~
        + CategoryInfo          : ObjectNotFound: (C:\Temp\Setup-C...el\con.ht
       ml:String) [Get-Content], ItemNotFoundException
        + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetCo
       ntentCommand

    @jrv - Please learn to be more polite and less like a pompous ass.
    I've been staring at the problem for a week before reaching out for help.  Yes it's a stupid typo that I should have seen during one of the dozens of times I reviewed the code - but I didn't.  I'll bet you've encountered stupid mistakes before
    too.  Posting a rude, arrogant comment on this thread after someone had already answered my question is something only a jerk would do.
    Please learn to read the messages.
    I said please.  How polite do you want it.  You need to learn to use the information that is right in front of you.  It willsave you all of those wasted weeks caused by refusing to take well intended advice.
    ¯\_(ツ)_/¯

  • What is wrong with my Get-Content

    I have a very simple script that for some reason fails me when I try to use the Get-Content issue. 
    $scriptLoc = [string](Get-Location)
    $path = $scriptLoc + '\temp_folder\'
    $files = Get-ChildItem -Path $path -filter hello*.txt
    write-host $files
    So this works fine. It goes to this destination. C:\Scripts\temp_folder
    In this folder are two files. 
    1. hello_dave.txt
    2.bye_dave.txt
    when I run the script above it successfully only shows file 1.
    So why does it fail with this?
    $file = Get-Content $files
    Actually I know why it fails, but why it fails make no sense. It returns an error saying that it cannot find the path. 
    The path it lists is not the one I have setup. This is the folder the txt file is in, and what I have setup earlier. C:\Scripts\temp_folder
    This is what it returns instead. Cannot find path 'C:\Scripts\hello_dave.txt' because it does not exist. 

    Please, before telling people they are making up stuff do test the exact steps as posted, we call it reproducing the issue.
    But don't bother I did it for you:
    PS C:\scripts> $scriptLoc = [string](Get-Location)
    PS C:\scripts> $path = $scriptLoc + '\temp_folder\'
    PS C:\scripts> $files = Get-ChildItem -Path $path -filter hello*.txt
    PS C:\scripts> write-host $files
    hello_dave.txt
    PS C:\scripts> Get-Content $files
    Get-Content : Cannot find path 'C:\scripts\hello_dave.txt' because it does not exist.
    At line:1 char:1
    + Get-Content $files
    + ~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (C:\scripts\hello_dave.txt:String) [Get-Content], ItemNotFoundException
        + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand
    PS C:\scripts> Get-Content $files.PSPath
    test
    Your example works fine but not in the contest of the reported issue. As you can see $files is not NULL but resolves to C:\scripts\hello_dave.txt 

  • I have a 120gb Classic that has no space left on it. i am going to buy a larger gb capacity ipod as soon as i get clearer instruction on how to get the old ipod content to the new ipod. How do you get content from one ipod to the other?

    how do you get content from one ipod to the new one? my content is on an external hard drive not on my pc and i have run out of space on my 120gb classic. can you get old ipod content to new? my itunes has only got short cuts, the real content is on an external drive? can this be done?? please help

    If the content is on an external drive, but your library knows where to find it, then it should all work. Connect your device, make some selections for what to put on it, and sync. If, on the other hand, your current iPod is the only place holding some of your media then see this user tip: Recover your iTunes library from your iPod or iOS device.
    tt2

  • How do I set up automatic downloads so that i only get content from specific devices?

    Hello! I was wondering if there was a way I could set up automatic downloads so I only get content purchased from certain devices. I have a MacBook Pro and a ipod touch. I share an apple id with my family for itunes but have my own apple id for icloud. In my family we have various other apple products (iphones and ipads) and I dont want most of the things that my family would download on their devices - just the things would happen to download on my ipod and computer.
    Thanks for the help,
    J

    jackson_7 wrote:
    Hello! I was wondering if there was a way I could set up automatic downloads so I only get content purchased from certain devices.........
    That's not possible sorry.

  • How do I get content from my iPad to show up on the tv screen using Apple TV without going thru iTunes?

    How can I get content from my iPad and my air book to show up on the tv screen using Apple TV, without going thru iTunes?

    You will need to use AirPlay to see that.
    Assuming both devices are on the same network and that AirPlay is not turned off on the Apple TV, then simply tap on the screen when you are watching content you wish to stream to your Apple TV, then tap the airplay icon that appears in the control bar, choose the Apple TV from the menu that appears.
    When displaying the content you wish to mirror on the iPad 2 (or better), iPad Mini, iPhone 4S (or better), double tap the home button (quickly) and swipe the bottom row of apps to the right to reveal the playback controls, tap the AirPlay icon and select your Apple TV from the list of available devices.

  • I have an Iphone 3Gs. I need to get contents of messages that were sent and received on the phone in June for evidence in court. I read online that the Iphone internal storage keeps all data done on phone in the storage. How do I get into it?

    I have an Iphone 36s. I need to get contents of messages that were sent on the phone in June of this year. I read online that the phone has an internal storage that keeps all data when phone is used and that this internal storage can be accessed. I need the contents of particular messages for evidence in court. How do I get into the internal storage? I've tried some of the methods that people post online, but none of them have been successful. Help!

    If you still have a backup from that point in time as part ofr your computer backup history, you could restore the backup folder, restore the phone from that backup and have the messages on the phone.
    More details about restoring from old backups can be found here: iPhone and iPod touch: About backups

  • Get-Content and add Date and Time in a new file

    Hello,
    in a existing file I have data like:
    1;Idle
    5;chrome
    1;spoolsv
    Now I need to grab the content and add date and time in front of each line and save it to another file like:
    07.04.2015;10:18;1;Idle
    07.04.2015;10:18;5;chrome
    07.04.2015;10:18;1;spoolsv
    But I don't have any idea how I could solve this challange. Does anyone have a helping hand for me?
    Greetings

    Hello,
    If you need a new file with the desired output try this
    get-content .\current.txt | Foreach-Object{ $dntv = (get-date) ; "$dntv" + $_} | Out-File newfile.txt
    regards,
    V
    Venu

  • My last pc crashed, how do i get content from ipod/iphone/ipad and previously purchased items back into itunes on pc?

    How do I get content back into itunes from ipod/iphone and ipad when old pc died and now have a blank itunes?

    check out this post by Zevoneer.

Maybe you are looking for