rest

xml – Call REST Request inside XSLT and copy only some elements


I am attempting to make a REST call inside my XSL that will incorporate only parts of the response into the original transformed XML doc. I found one example that talked about using variables and the document() function, but I can’t seem to get it to work.

Here is the original XML document:

<?xml version="1.0" encoding="UTF-8"?>
<PublishPELTEST xmlns="http://www.ibm.com/maximo" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
creationDateTime="2018-02-08T09:15:08-05:00" transLanguage="EN" 
baseLanguage="EN" messageID="1518099308834189587" maximoVersion="7 5 2 12" 
event="0">
  <PELTESTSet>
    <WORKORDER>
      <DESCRIPTION>My Workorder Description</DESCRIPTION>
      <WONUM>MWO-522</WONUM>
      <WOPRIORITY>3</WOPRIORITY>
      <WORKORDERID>2255202</WORKORDERID>
      <ASSIGNMENT>
        <LABORCODE>006325</LABORCODE>
      </ASSIGNMENT>
      <KUBROUNDENTRY>
        <KUBROUNDENTRYID>267433</KUBROUNDENTRYID>
        <LINEID>254735</LINEID>
        <OBSERVATION />
        <KUBROUNDLINE>
          <ASSETNUM>385691</ASSETNUM>
          <METERNAME>VLOPSTAT</METERNAME>
          <SEQUENCE>90</SEQUENCE>
          <ASSET>
            <ASSETID>388391</ASSETID>
            <DESCRIPTION>Asset Description</DESCRIPTION>
            <SERVICEADDRESS>
              <STREETADDRESS>1234 Kingston Pike</STREETADDRESS>
            </SERVICEADDRESS>
          </ASSET>
          <METER>
            <DOMAINID>VLOPSTAT</DOMAINID>
            <METERNAME>VLOPSTAT</METERNAME>
          </METER>
        </KUBROUNDLINE>
      </KUBROUNDENTRY>
      <KUBROUNDENTRY>
        <KUBROUNDENTRYID>267432</KUBROUNDENTRYID>
        <LINEID>254734</LINEID>
        <OBSERVATION />
        <KUBROUNDLINE>
          <ASSETNUM>385691</ASSETNUM>
          <METERNAME>GLEAKGRD</METERNAME>
          <SEQUENCE>80</SEQUENCE>
          <ASSET>
            <ASSETID>388391</ASSETID>
            <DESCRIPTION>Asset2 Description</DESCRIPTION>
            <SERVICEADDRESS>
              <STREETADDRESS>2345 Kingston Pike</STREETADDRESS>
            </SERVICEADDRESS>
          </ASSET>
          <METER>
            <DOMAINID>CASEGRDE</DOMAINID>
            <METERNAME>GLEAKGRD</METERNAME>
          </METER>
        </KUBROUNDLINE>
      </KUBROUNDENTRY>
    </WORKORDER>
  </PELTESTSet>
</PublishPELTEST>

This is the REST request and the result that is returned normally:
http://server.loc.org/maxrest/rest/mbo/alndomain/?domainid=’SKIPRSN’

<?xml version="1.0" encoding="UTF-8"?>
<ALNDOMAINMboSet rsStart="0" xmlns="http://www.ibm.com/maximo" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <ALNDOMAIN xmlns="http://www.ibm.com/maximo" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <DOMAINID>KUBSKIPRSN</DOMAINID>
        <VALUE>TRAFFIC</VALUE>
        <DESCRIPTION>Traffic Control Needed</DESCRIPTION>
        <ALNDOMAINID>4906</ALNDOMAINID>
        <VALUEID>KUBSKIPRSN|TRAFFIC</VALUEID>
    </ALNDOMAIN>
    <ALNDOMAIN xmlns="http://www.ibm.com/maximo" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <DOMAINID>KUBSKIPRSN</DOMAINID>
        <VALUE>NOT FOUND</VALUE>
        <DESCRIPTION>Asset Not Found</DESCRIPTION>
        <ALNDOMAINID>4006</ALNDOMAINID>
        <VALUEID>KUBSKIPRSN|NOT FOUND</VALUEID>
    </ALNDOMAIN>
    <ALNDOMAIN xmlns="http://www.ibm.com/maximo" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <DOMAINID>KUBSKIPRSN</DOMAINID>
        <VALUE>SKIP ALL</VALUE>
        <DESCRIPTION>Skip All</DESCRIPTION>
        <ALNDOMAINID>3802</ALNDOMAINID>
        <VALUEID>KUBSKIPRSN|SKIP ALL</VALUEID>
    </ALNDOMAIN>
</ALNDOMAINMboSet>

What I had read previously about this was that you had to add the namespace to your xsl. In this case, I believe the namespace is the same namespace as my origianl XML document. So, I guessed that no other references were necessary.??

With that assumption, I ran the XSL below and it does not pull back any information related to the REST request.

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:mea="http://www.ibm.com/maximo" exclude-result-prefixes="mea"
    version="1.0">
    <xsl:output method="xml" cdata-section-elements="" />

    <xsl:template match="/">
      <yyy:createJob xmlns:yyy="http://place.org/mmm/app">
        <job>
          <id />
          <origin>AMS</origin>
          <metaId>
            <xsl:value-of select="descendant::mea:WORKORDERID" />
          </metaId>
          <title>
            <xsl:value-of select="descendant::mea:DESCRIPTION" />
          </title>
          <dispatchGroup>FWSAMS</dispatchGroup>
          <priority>
            <xsl:value-of select="descendant::mea:WOPRIORITY" />
          </priority>
          <assignedTo>
            <xsl:value-of 
                select="descendant::mea:ASSIGNMENT/mea:LABORCODE" />
          </assignedTo>
          <jobDocument>
            <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
              <root>
                <workorderNum>
                  <xsl:value-of select="descendant::mea:WONUM" />
                </workorderNum>
                <xsl:apply-templates mode="copy"
                      select="descendant::mea:KUBROUNDENTRY" />
                <skipReasonDomain>
                  <xsl:variable name="myDomain">
                    <xsl:text>SKIPRSN</xsl:text>
                  </xsl:variable>
                  <xsl:value-of 
 select="document(concat('http://server.loc.org/maxrest/rest/mbo/alndomain/?
 domainid=',$myDomain))/descendant::VALUE"/>
                </skipReasonDomain>
              </root>
              <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
            </jobDocument>
            <completionDocument />
          </job>
        </yyy:createJob>
      </xsl:template>

    <xsl:template match="*" mode="copy">
    <xsl:element name="{local-name()}">
        <xsl:apply-templates select="node()" mode="copy" />
    </xsl:element>
    </xsl:template>

    <xsl:template match="text()|comment()" mode="copy">
      <xsl:copy/>
    </xsl:template>

</xsl:stylesheet>

This is the resulting XML document:

<yyy:createJob
xmlns:yyy="http://place.org/mmm/app">
<job>
    <id></id>
    <origin>AMS</origin>
    <metaId>2255202</metaId>
    <title>My Workorder Description</title>
    <dispatchGroup>FWSAMS</dispatchGroup>
    <priority>3</priority>
    <assignedTo>006325</assignedTo>
    <jobDocument>
        <![CDATA[<root><workorderNum>MWO-522</workorderNum><KUBROUNDENTRY><KUBROUNDENTRYID>267433</KUBROUNDENTRYID><LINEID>254735</LINEID><OBSERVATION/><KUBROUNDLINE><ASSETNUM>385691</ASSETNUM><METERNAME>VLOPSTAT</METERNAME><SEQUENCE>90</SEQUENCE><ASSET><ASSETID>388391</ASSETID><DESCRIPTION>Asset Description</DESCRIPTION><SERVICEADDRESS><STREETADDRESS>1234 Kingston Pike</STREETADDRESS></SERVICEADDRESS></ASSET><METER><DOMAINID>VLOPSTAT</DOMAINID><METERNAME>VLOPSTAT</METERNAME></METER></KUBROUNDLINE></KUBROUNDENTRY><KUBROUNDENTRY><KUBROUNDENTRYID>267432</KUBROUNDENTRYID><LINEID>254734</LINEID><OBSERVATION/><KUBROUNDLINE><ASSETNUM>385691</ASSETNUM><METERNAME>GLEAKGRD</METERNAME><SEQUENCE>80</SEQUENCE><ASSET><ASSETID>388391</ASSETID><DESCRIPTION>Asset2 Description</DESCRIPTION><SERVICEADDRESS><STREETADDRESS>2345 Kingston Pike</STREETADDRESS></SERVICEADDRESS></ASSET><METER><DOMAINID>CASEGRDE</DOMAINID><METERNAME>GLEAKGRD</METERNAME></METER></KUBROUNDLINE></KUBROUNDENTRY><skipReasonDomain/></root>]]>
    </jobDocument>
    <completionDocument></completionDocument>
</job>
</yyy:createJob>

My desired output would be:

<yyy:createJob
xmlns:yyy="http://place.org/mmm/app">
<job>
    <id></id>
    <origin>AMS</origin>
    <metaId>2255202</metaId>
    <title>My Workorder Description</title>
    <dispatchGroup>FWSAMS</dispatchGroup>
    <priority>3</priority>
    <assignedTo>006325</assignedTo>
    <jobDocument>
        <![CDATA[<root><workorderNum>MWO-522</workorderNum><KUBROUNDENTRY><KUBROUNDENTRYID>267433</KUBROUNDENTRYID><LINEID>254735</LINEID><OBSERVATION/><KUBROUNDLINE><ASSETNUM>385691</ASSETNUM><METERNAME>VLOPSTAT</METERNAME><SEQUENCE>90</SEQUENCE><ASSET><ASSETID>388391</ASSETID><DESCRIPTION>Asset Description</DESCRIPTION><SERVICEADDRESS><STREETADDRESS>1234 Kingston Pike</STREETADDRESS></SERVICEADDRESS></ASSET><METER><DOMAINID>VLOPSTAT</DOMAINID><METERNAME>VLOPSTAT</METERNAME></METER></KUBROUNDLINE></KUBROUNDENTRY><KUBROUNDENTRY><KUBROUNDENTRYID>267432</KUBROUNDENTRYID><LINEID>254734</LINEID><OBSERVATION/><KUBROUNDLINE><ASSETNUM>385691</ASSETNUM><METERNAME>GLEAKGRD</METERNAME><SEQUENCE>80</SEQUENCE><ASSET><ASSETID>388391</ASSETID><DESCRIPTION>Asset2 Description</DESCRIPTION><SERVICEADDRESS><STREETADDRESS>2345 Kingston Pike</STREETADDRESS></SERVICEADDRESS></ASSET><METER><DOMAINID>CASEGRDE</DOMAINID><METERNAME>GLEAKGRD</METERNAME></METER></KUBROUNDLINE></KUBROUNDENTRY><skipReasonDomain><VALUE>TRAFFIC</VALUE><VALUE>NOT FOUND</VALUE><VALUE>SKIP ALL</VALUE></root>]]>
    </jobDocument>
    <completionDocument></completionDocument>
</job>
</yyy:createJob>

I know this is a lot of information, but I hope it helps someone to understand what I am trying to do and how I might be able to get there. Any information is much appreciated.



لینک منبع

json – Kie Rest client using Java


I am new to rest services ,I am using SOAPUI to call POST method same I want to do using java. I have tried many code samples available but didn’t worked for me.
I am using basic authentication with username and password, in header I have set “X-KIE-ContextType” to “json”. media type – application/json and used following data to pass to service

{“lookup” : “defaultKieSession”,
“commands” : [

{"insert" : {"out-identifier":"cust1","return-object":true,"entry-point":"DEFAULT","object":{"com.css":{
    "overdue":100
 }}}},

{"fire-all-rules" : {} },{"get-objects": {"out-identifier":"cust1"}}
]

}

Which API I can use.



لینک منبع

Django Rest Framework and Graphene comparison


I want to develop a django application with Vue.js which needs JSON data. As a result of my research both Django Rest Framework (DRF) and Graphene will help me give me the JSON data I need. I am now incline to learn and use Graphene because:

  1. They say Graphql is better than REST API
  2. DRF is more than just giving JSON data so I think it could be too much to use DRF just for the JSON data for the Vue.js
  3. Graphene looks to have shorter learning curve than DRF

Are all my thoughts right? Please correct me



لینک منبع

javascript – REST API get call with credentials


I have trying to call ServiceNow API from a SharePoint hosted adding i’m working on using JavaScript with credential for the header. But when i try to run it during the run time the request gets an error. Any help regarding this would be highly appreciated.

$(“#apibutton”).click(function () {

    var req = new XMLHttpRequest();

    req.open('GET', URL, true);
    req.setRequestHeader('Content-Type', 'application/json');

    req.open("Authorization", "Basic " + btoa(Username + ":" + password));
    req.withCredentials = true;
    req.send();
    alert("here1");

    if (req.readyState === 4) {
        if (req.status === 200) {
            console.log(xhr.responseText);
            var response = JSON.parse(req.responseText);
            alert("here2");
        } else {
            console.error(req.statusText);
            alert("error");
        }
    }
}



لینک منبع

Apple finally catches up with the rest of the world and joins Instagram


Apple is getting a bit more social.

The notoriously social media-shy tech giant just launched a new Instagram account to showcase some of the best photos taken with the iPhone.

Like Apple’s long-running “Shot on iPhone” campaign, @Apple will exclusively feature curated and credited photos from iPhone users all over the world. The company says product photo galleries, commercials or other company marketing will never appear on the account.

The idiosyncratic Cupertino company has long eschewed advertising on competitor platforms, but it’s loosened up a bit on that stance in the past couple years. It’s opened Instagram, Twitter, and Snapchat accounts for Apple Music, Twitter accounts for iTunes and iBooks, and it had its long-dormant @Apple account officially verified last fall.

The fledgling account was stocked with four videos at launch — one introductory post and three artist-narrated galleries.

Instagram users can have their photos considered for a feature spot on the account by tagging them with the hashtag #ShotOnIphone. Apple says it will never use anyone’s photos without their permission.

Apple’s marketing material has been ramping up its emphasis on the creative capabilities of the iPhone in recent years with efforts like the “Shot on iPhone” campaign and in-store photography and video classes. The thinking seems to be that iPhone users who are more invested in device-related hobbies are more likely to care about increasingly incremental upgrades to its capabilities, and thus more likely to buy each new version of the phone.

Https%3a%2f%2fvdist.aws.mashable.com%2fcms%2f2017%2f7%2fea8cdb04 3ea2 94b3%2fthumb%2f00001

 

 



لینک منبع

Ivanka learned about her dad’s transgender military ban just like the rest of us — on Twitter


Ivanka Trump, who has to pay very close attention to her dad's tweets.
Ivanka Trump, who has to pay very close attention to her dad’s tweets.

Image: Sean Gallup/Getty Images

Ivanka Trump may share the president’s blood and hold a position in the White House, but when it comes to learning about her father’s impromptu announcements, she finds out same way as the rest of the world: Twitter.

In fact, according to Politico, Trump’s eldest daughter had absolutely no idea her father was planning to issue his ban on transgender people in the military last week, which just goes to show how great communication is at the White House. 🙃

In the article, Politico writers Annie Karni and Eliana Johnson describe Ivanka and her husband, White House advisor Jared Kushner, as being “blindsided” by Trump’s three tweets banning transgender people from serving in the military and describing their medical expenses as burdensome and disruptive.

While defense secretary Jim Mattis was reportedly given only a day’s notice about the decision, White House officials told the publication Ivanka was “surprised by her father’s posts” and didn’t learn of the decision until seeing Trump’s tweet on her phone. Same, girl. Same — though Trump’s not my dad.

During his campaign, the president pledged to fight for the freedoms of the LGBTQ community, but he’s done little to uphold those promises since taking office. In February, Trump rescinded the Obama-era rule allowing transgender students to use the restroom matching their gender identity, and despite serious backlash from the LGBTQ community, he failed to proclaim June National Pride Month.

In the past, Ivanka has been vocal about her support of LGBTQ rights. After her father took office, she and Kushner reportedly helped put an end to an executive order that would have overturned additional Obama-era transgender protections and allowed people in the workplace to discriminate against members of the LGBTQ community on the basis of religious beliefs.

Trump may have declared his ban via Twitter, but chairman of the Joint Chiefs of Staff, Marine General Joe Dunford, explained in an internal memo obtained by Politico that tweets do not make official policies … Sad! 

“There will be no modifications to the current policy until the President’s direction has been received by the Secretary of Defense and the Secretary has issued implementation guidance,” Dunford wrote. “In the meantime, we will continue to treat all of our personnel with respect … and will all remain focused on accomplishing our assigned missions.”

It comes as no surprise that Ivanka is now getting backlash. “Actions speak louder than words,” Sarah McBride, national press secretary for the nonprofit Human Rights Coalition told Politico. “Either Ivanka is ineffective in her advocacy within the building, or her voice doesn’t matter to the president as much as she hopes it does.”

Looks like Ivanka needs to step up her game. Though, in her defense, it appears that once Trump drafts a tweet there’s nothing standing in the way of him sharing it with the world … not even immediate family members.

Better turn on push notifications, guys!

Https%3a%2f%2fblueprint api production.s3.amazonaws.com%2fuploads%2fvideo uploaders%2fdistribution thumb%2fimage%2f80980%2f8c12dc13 0db5 4d2f af2e ab99771f2d29



لینک منبع