I've created a value help annotation for field form/CompanyCode, see metadata below:
<EntityType sap:content-version="1" Name="shBukrs">
<Key>
<PropertyRef Name="Bukrs"/>
</Key>
<Property Name="Bukrs" sap:label="Company Code" Type="Edm.String" MaxLength="4" sap:creatable="false" Nullable="false"/>
<Property Name="Butxt" sap:filterable="false" sap:sortable="false" sap:updatable="false" sap:label="Company Name" Type="Edm.String" MaxLength="25" sap:creatable="false" Nullable="false"/>
<Property Name="Ort01" sap:filterable="false" sap:sortable="false" sap:updatable="false" sap:label="City" Type="Edm.String" MaxLength="25" sap:creatable="false" Nullable="false"/>
<Property Name="Waers" sap:filterable="false" sap:sortable="false" sap:updatable="false" sap:label="Currency" Type="Edm.String" MaxLength="5" sap:creatable="false" Nullable="false" sap:semantics="currency-code"/>
</EntityType>
<Annotation Term="com.sap.vocabularies.Common.v1.ValueList">
<Record>
<PropertyValue String="shBukrsSet" Property="CollectionPath"/>
<PropertyValue Property="SearchSupported" Bool="true"/>
<PropertyValue Property="Parameters">
<Collection>
<Record Type="com.sap.vocabularies.Common.v1.ValueListParameterOut">
<PropertyValue Property="LocalDataProperty" PropertyPath="CompanyCode"/>
<PropertyValue String="Bukrs" Property="ValueListProperty"/>
</Record>
<Record Type="com.sap.vocabularies.Common.v1.ValueListParameterDisplayOnly">
<PropertyValue String="Butxt" Property="ValueListProperty"/>
</Record>
</Collection>
</PropertyValue>
</Record>
</Annotation>
</Annotations>
I've added the field to the form:
<smartField:SmartLabel labelFor="idCompanyCode"/>
<smartField:SmartField value="{CompanyCode}" id="idCompanyCode"/>
but the value help is not attached to the field on the form (no value help button)...
Anyone any idea what's wrong?
Solved... target service name was missing:
Old:
<Annotation Term="com.sap.vocabularies.Common.v1.ValueList">
New:
<Annotation Term="com.sap.vocabularies.Common.v1.ValueList" Target="<service>">
Please make sure that you use the Registered Service name as Target value.
Related
I'm tying to call an OAuth token service to retrieve the token.
Below is my proxy. This is a simple rest endpoint call which retrieves the token. For testing purpose I'm trying to log the token in the response.
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="sla_proxy_svc_vo2" startOnLoad="true" trace="disable"
transports="http https" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<log level="custom">
<property name="msg" value="*****INITIATING*****" />
</log>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:echo="http://echo.services.core.carbon.wso2.org"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<nstxt:text xmlns:nstxt="http://ws.apache.org/commons/ns/payload">grant_type=client_credentials&client_id=G6Dk_3ZdrXOfPiuctufVq6GfTWoa&client_secret=jxA8NTkEClE5xGUvGvvhVTDyXM4a</nstxt:text>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args />
</payloadFactory>
<log level="custom">
<property name="msg" value="*****BEFORE TOKEN SERVICE CALL*****" />
</log>
<log level="full" />
<property name="HTTP_METHOD" scope="axis2" type="STRING"
value="POST" />
<property name="messageType" scope="axis2" type="STRING"
value="text/plain" />
<property name="ContentType" scope="axis2" type="STRING"
value="text/plain" />
<property name="Accept" scope="axis2" type="STRING"
value="application/json" />
<send>
<endpoint>
<http format="rest" method="post" trace="disable"
uri-template="http://10.236.70.9:8281/token" />
</endpoint>
</send>
</inSequence>
<outSequence>
<log level="custom">
<property name="msg" value="******OUT SEQUENCE*******" />
</log>
<log level="full" />
<send />
</outSequence>
<faultSequence />
</target>
</proxy>
I'm getting the below response when I call.
DEBUG {org.apache.synapse.transport.http.wire} - << "HTTP/1.1 415 Unsupported Media Type[\r][\n]" {org.apache.synapse.transport.http.wire}
DEBUG {org.apache.synapse.transport.http.wire} - << "X-Frame-Options: DENY[\r][\n]" {org.apache.synapse.transport.http.wire}
DEBUG {org.apache.synapse.transport.http.wire} - << "X-XSS-Protection: 1; mode=block[\r][\n]" {org.apache.synapse.transport.http
Will be please if anyone can guide me of I'm doing anything wrong here.
I was able to call the service with the following payload.
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<root>
<grant_type>client_credentials</grant_type>
<client_id>G6Dk_3ZdrXOfPiuctufVq6GfTWoa</client_id>
<client_secret>jxA8NTkEClE5xGUvGvvhVTDyXM4a</client_secret>
</root>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args />
</payloadFactory>
Also had to add the content type as below.
<property name="messageType" scope="axis2" type="STRING" value="application/x-www-form-urlencoded" />
<property name="ContentType" scope="axis2" type="STRING" value="application/x-www-form-urlencoded" />
This worked and retrieved the token.
Here is a template I'm using in a component to set the oAuth token, you could probably adapt it a bit for your case (sounds like you do not need grantType or user credentials)
<?xml version="1.0" encoding="UTF-8"?>
<template name="getToken" xmlns="http://ws.apache.org/ns/synapse">
<parameter name="tokenURL"/>
<parameter name="clientId"/>
<parameter name="clientSecret"/>
<parameter name="grantType"/>
<sequence>
<property description="Base64 crendetials" expression="base64Encode(fn:concat($func:clientId,':',$func:clientSecret))" name="credentials" scope="default" type="STRING"/>
<property description="Authentication" expression="fn:concat('Basic ', get-property('credentials'))" name="Authorization" scope="transport" type="STRING"/>
<header name="Content-Type" scope="transport" value="application/x-www-form-urlencoded"/>
<property name="messageType" scope="axis2" type="STRING" value="application/x-www-form-urlencoded"/>
<property name="DISABLE_CHUNKING" scope="axis2" type="STRING" value="true"/>
<property expression="$func:tokenURL" name="uri.var.authUrl" scope="default" type="STRING"/>
<property expression="$func:grantType" name="uri.var.grantType" scope="default" type="STRING"/>
<call blocking="true">
<endpoint>
<http method="post" uri-template="{uri.var.authUrl}?grant_type={uri.var.grantType}"/>
</endpoint>
</call>
<property expression="json-eval($.access_token)" name="OAuth_Token" scope="default" type="STRING"/>
<property action="remove" description="Remove Headers" name="TRANSPORT_HEADERS" scope="axis2"/>
<property description="Authorization" expression="fn:concat('Bearer ',get-property('OAuth_Token'))" name="Authorization" scope="transport" type="STRING"/>
</sequence>
</template>
I trying to retrive a token OAuth2. But I don't khnow how I can make a x-www-form-urlencoded request using wso2esb.
This is a snippet of my code:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="test-oauth_v1" xmlns="http://ws.apache.org/ns/synapse">
<in>
<property name="RESPONSE" scope="default" value="true"/>
<property action="remove" name="NO_ENTITY_BODY" scope="axis2"/>
<header action="remove" name="To"/>
<property name="messageType" value="application/json" scope="axis2" type="STRING"/>
<property name="basicAuth" scope="default" type="STRING" value="Z3FZVFhUQnhkQlVGNDloblxxzedtSGRBQ1kySWpmSmNvZXdh"/>
<script language="js"><![CDATA[
var body = {};
body.grant_type = 'password';
body.username = 'xxxx';
body.password = 'xxxxxxx';
mc.setPayloadJSON(body);
]]></script>
<property name="messageType" scope="default" type="STRING" value="application/x-www-form-urlencoded"/>
<header
expression="fn:concat('Basic ', get-property('basicAuth'))"
name="Authorization" scope="transport" xmlns:ns="http://org.apache.synapse/xsd"/>
<call>
<endpoint key="server_token_oauth"/>
</call>
<send />
</in>
</sequence>
Would you have any propositions ?
Best regards
You can refer this example [1]. Scope of the messageType should be axis2.
<property name="messageType" value="application/x-www-form-urlencoded" scope="axis2" type="STRING"/>
<property name="DISABLE_CHUNKING" value="true" scope="axis2" type="STRING"/>
Given I have the following relationship: one project can have multiple members and one member can be assigned to multiple projects.
Project(*)-------(*)Member
For the first time I only want to retrieve the members that are assigned to a specific project. Here is my current oData metadata and json model configuration:
JSON Model for Project:
[
{
"Id": 1,
"Title": "Project 0",
"MemberIds": [1,2]
},
{
"Id": 2,
"Title": "Project 1",
"MemberIds": [3,4]
}
]
JSON Model for Member
[
{
"Id": 1,
"FirstName": "Robyn"
},
{
"Id": 2,
"FirstName": "Romero"
}
{
"Id": 3,
"FirstName": "Hattie",
},
{
"Id": 4,
"FirstName": "Chandra"
}
]
oData Metadata
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="1.0"
xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
<edmx:DataServices m:DataServiceVersion="2.0"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<Schema Namespace="NAMESPACE" xml:lang="en"
xmlns="http://schemas.microsoft.com/ado/2008/09/edm"
xmlns:sap="http://www.sap.com/Protocols/SAPData">
<EntityType Name="Member" sap:content-version="1">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="Edm.Int32" Nullable="false" sap:label="Member Id"/>
<Property Name="FirstName" Type="Edm.String" Nullable="false"
MaxLength="255" sap:label="Member First Name" />
</EntityType>
<EntityType Name="Project" sap:content-version="1">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="Edm.Int32" Nullable="false" sap:label="Project Id"/>
<Property Name="Title" Type="Edm.String" Nullable="false"
MaxLength="255" sap:label="Project Title" />
<Property Name="MemberIds" Type="Collection(Edm.Int32)" sap:label="Project Member Ids" />
<NavigationProperty
FromRole="Project_toMembers"
Name="Members"
Relationship="NAMESPACE.ProjectToMembers"
ToRole="Member_toProjects" />
</EntityType>
<Association Name="ProjectToMembers" sap:content-version="1">
<End Role="Project_toMembers" Multiplicity="*" Type="NAMESPACE.Project"/>
<End Role="Member_toProjects" Multiplicity="*" Type="NAMESPACE.Member"/>
<ReferentialConstraint>
<Principal Role="Project_toMembers">
<PropertyRef Name="MemberIds"/>
</Principal>
<Dependent Role="Member_toProjects">
<PropertyRef Name="Id"/>
</Dependent>
</ReferentialConstraint>
</Association>
<EntityContainer Name="NAMESPACE"
m:IsDefaultEntityContainer="true">
<EntitySet Name="Projects" EntityType="NAMESPACE.Project"
sap:pageable="false" sap:content-version="1" />
<EntitySet Name="Members" EntityType="NAMESPACE.Member"
sap:pageable="false" sap:content-version="1" />
<AssociationSet
Name="Project_Member"
Association="NAMESPACE.ProjectToMembers">
<End Role="Project_toMembers" EntitySet="Members" />
<End Role="Member_toProjects" EntitySet="Projects" />
</AssociationSet>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
The request http://mymockserver/Projects(1)?$expand=Members returns the project with the given id but the attribute members is empty and does not contain - as expected - the member objects with the associated id's 1 and 2.
I hope someone can help me :)
My guess the following is not a supported type
Type="Collection(Edm.Int32)"
take a look at MockServer source, "Collection" doesn't seem to referenced as a type.
And it isn't listed as an allowed OData type, i did a quick search of the library and can only find 'Collection' referenced in DataJS.
You may still be able to cater for it in the MockServer if you Add Your Own Requests to SAPUI5 MockServer. Another thing I haven't as yet seen "Collections" as a type in either SAP Gateway or HANA XS, but guessing it is supported in Apache Olingo client and producer.
I am also trying to do something similar, but haven't managed to do so. If you look at the Cart example that comes with the UI5 SDK, you will see that they also haven't managed to do this. They get the complete entity set and then just filter the data for the selected item.
I am trying to create en entry in my local OData service like in this example
Using Postman I am making a POST request on https://localhost:8090/odata/titles with this JSON body
{
"#odata.type":"SAPSybaseOData.titles",
"title_id":"ZZ1234",
"title":"new book",
"type":"business",
"pub_id":"1390",
"price":1,
"advance":1,
"total_sales":1,
"notes":"note",
"pubdate":"/Date(581817600000)/",
"contract":true
}
the OData service response status code is 400 - Bad request with this XML body
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code>30068</code>
<message xml:lang="en-US">An error occurred while parsing the request body.</message>
</error>
my OData service metadata is
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0">
<edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="1.0">
<Schema xmlns="http://schemas.microsoft.com/ado/2008/09/edm" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" Namespace="SAPSybaseOData">
<EntityType Name="titles">
<Key>
<PropertyRef Name="title_id" />
</Key>
<Property Name="title_id" Type="Edm.String" Nullable="false" MaxLength="6" Unicode="false" Collation="cp850" />
<Property Name="title" Type="Edm.String" Nullable="false" MaxLength="80" Unicode="false" Collation="cp850" />
<Property Name="type" Type="Edm.String" Nullable="false" MaxLength="12" Unicode="false" Collation="cp850" FixedLength="true" />
<Property Name="pub_id" Type="Edm.String" Nullable="true" MaxLength="4" Unicode="false" Collation="cp850" />
<Property Name="price" Type="Edm.Decimal" Nullable="true" Precision="14" Scale="4" />
<Property Name="advance" Type="Edm.Decimal" Nullable="true" Precision="14" Scale="4" />
<Property Name="total_sales" Type="Edm.Int32" Nullable="true" />
<Property Name="notes" Type="Edm.String" Nullable="true" MaxLength="200" Unicode="false" Collation="cp850" />
<Property Name="pubdate" Type="Edm.DateTime" Nullable="false" Precision="3" />
<Property Name="contract" Type="Edm.Boolean" Nullable="false" />
</EntityType>
<EntityContainer Name="SAPSybaseOData_Container" m:IsDefaultEntityContainer="true">
<EntitySet Name="titles" EntityType="SAPSybaseOData.titles" />
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
How can I create a new entry like in this example ?
Am I missing something ? How come the example is working fine and I get a parsing error ?
Using breeze.js (master branch) and angular on client with odata4j on the server-side, I'm receiving the following error if i want to query for countries:
var query = breeze.EntityQuery.from('Country');
entityManager.executeQuery(query).then(...).fail(...);
-> Unable to locate a 'Type' by the name: Country:#odataContainer
I've configured breeze as follows:
breeze.config.initializeAdapterInstances({dataService: "OData"});
breeze.NamingConvention.none.setAsDefault();
.../$metadata OData response:
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
<edmx:DataServices m:DataServiceVersion="2.0" xmlns:m="...">
<Schema Namespace="odataContainer" xmlns="...">
<EntityContainer Name="odataEntities" m:IsDefaultEntityContainer="true">
<EntitySet Name="Country" EntityType="odataModel.Country">
</EntitySet>
</EntityContainer>
</Schema>
<Schema Namespace="odataModel" xmlns="...">
<EntityType Name="Country">
<Key>
<PropertyRef Name="countryCode"></PropertyRef>
</Key>
<Property Name="region" Type="Edm.String" Nullable="true"></Property>
<Property Name="population" Type="Edm.Int32" Nullable="false"></Property>
<Property Name="countryCode" Type="Edm.String" Nullable="false"></Property>
<Property Name="name" Type="Edm.String" Nullable="true"></Property>
</EntityType>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
You need to include namespace for you models in your project. In case your Country class is in odataModel.Country you need to add the third line to configure oData service:
ODataModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet<Department>("Countries");
builder.Namespace = "odataModel.Country";