Skip to content

Commit

Permalink
Change schema type enum to set of flags controling the transform
Browse files Browse the repository at this point in the history
  • Loading branch information
kenrowland committed Jul 17, 2023
1 parent 732446a commit 5f6e2cc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
19 changes: 10 additions & 9 deletions esp/bindings/http/platform/httpbinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1429,7 +1429,7 @@ void EspHttpBinding::getSoapMessage(StringBuffer& soapmsg, IEspContext& ctx, CHt
StringBuffer req, tag, schema, filtered;
msg->marshall(req, NULL);

getServiceSchema(ctx, request, serviceQName, methodQName, SCHEMA_SOAP, getVersion(ctx), schema);
getServiceSchema(ctx, request, serviceQName, methodQName, getVersion(ctx), false, false, schema);

getXMLMessageTag(ctx, true, methodQName, tag);
filterXmlBySchema(req,schema,tag.str(),filtered);
Expand Down Expand Up @@ -1729,7 +1729,7 @@ bool EspHttpBinding::getSchema(StringBuffer& schema, IEspContext &ctx, CHttpRequ
}

void EspHttpBinding::getServiceSchema(IEspContext& context, CHttpRequest* request, const char *serviceQName, const char *methodQName,
SchemaType schemaType, double version, StringBuffer &schema)
double version, bool isWsdl, bool addAnnotations, StringBuffer &schema)
{
IProperties *opts = context.queryRequestParameters();
EsdlXslTypeId esdlXslType = EsdlXslToXsd;
Expand All @@ -1752,7 +1752,7 @@ void EspHttpBinding::getServiceSchema(IEspContext& context, CHttpRequest* reque

//
// Selectively add parameters based on the type of schema requested
if (schemaType == SCHEMA_WSDL)
if (isWsdl)
{
params->setProp( "create_wsdl", "true()" );
StringBuffer location(m_wsdlAddress.str());
Expand All @@ -1763,7 +1763,8 @@ void EspHttpBinding::getServiceSchema(IEspContext& context, CHttpRequest* reque
params->setProp("location", StringBuffer("'").append(location).append("'").str());
esdlXslType = EsdlXslToWsdl;
}
else if (schemaType == SCHEMA_XFORM)

if (addAnnotations)
{
params->setProp( "all_annot_Param", "true()" );
}
Expand Down Expand Up @@ -1817,7 +1818,7 @@ int EspHttpBinding::getServiceWsdlOrXsd(IEspContext &context, CHttpRequest* requ

StringBuffer schema;
getServiceSchema(context, request, serviceQName, methodQName,
isWsdl ? SCHEMA_WSDL : SCHEMA_XSD, version, schema);
version, isWsdl, false, schema);

response->setContent(schema.length(), schema.str());
response->setContentType(HTTP_TYPE_APPLICATION_XML_UTF8);
Expand Down Expand Up @@ -1913,7 +1914,7 @@ void EspHttpBinding::generateSampleXml(bool isRequest, IEspContext &context, CHt
return;
}

getServiceSchema(context, request, serviceQName, methodQName, SCHEMA_XML, getVersion(context), schemaXml);
getServiceSchema(context, request, serviceQName, methodQName, getVersion(context), false, false, schemaXml);

Owned<IXmlSchema> schema;
IXmlType* type = nullptr;
Expand Down Expand Up @@ -1989,7 +1990,7 @@ void EspHttpBinding::generateSampleJson(bool isRequest, IEspContext &context, CH
return;
}

getServiceSchema(context, request, serviceQName, methodQName, SCHEMA_JSON, getVersion(context), schemaXml);
getServiceSchema(context, request, serviceQName, methodQName, getVersion(context), false, false, schemaXml);

Owned<IXmlSchema> schema;
IXmlType* type = nullptr;
Expand Down Expand Up @@ -2464,7 +2465,7 @@ int EspHttpBinding::onGetXForm(IEspContext &context, CHttpRequest* request, CHtt
double ver = getVersion(context);
StringBuffer schema;

getServiceSchema(context, request, serviceQName, methodQName, SCHEMA_XFORM, ver, schema);
getServiceSchema(context, request, serviceQName, methodQName, ver, false, true, schema);

StringBuffer page;
IXslProcessor* xslp = getXmlLibXslProcessor();
Expand Down Expand Up @@ -2768,7 +2769,7 @@ void EspHttpBinding::validateResponse(IEspContext& context, CHttpRequest* reques
}

// schema
getServiceSchema(context, request, serviceQName, methodQName, SCHEMA_VALIDATION, getVersion(context), xsd);
getServiceSchema(context, request, serviceQName, methodQName, getVersion(context), false, false, xsd);

// validation
if (getEspLogLevel()>LogMax)
Expand Down
11 changes: 1 addition & 10 deletions esp/bindings/http/platform/httpbinding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,17 +462,8 @@ class esp_http_decl EspHttpBinding :
void sortResponse(IEspContext& context, CHttpRequest* request,MemoryBuffer& contentconst,
const char *serviceName, const char* methodName);

enum SchemaType {
SCHEMA_WSDL,
SCHEMA_XSD,
SCHEMA_JSON,
SCHEMA_XML,
SCHEMA_SOAP,
SCHEMA_XFORM,
SCHEMA_VALIDATION
};
void getServiceSchema(IEspContext& context, CHttpRequest* request, const char *serviceQName, const char *methodQName,
SchemaType schemaType, double version, StringBuffer &schema);
double version, bool isWsdl, bool addAnnotations, StringBuffer &schema);
};

inline bool isEclIdeRequest(CHttpRequest *request)
Expand Down

0 comments on commit 5f6e2cc

Please sign in to comment.