[xsd-users] XML string over Google Protocol Buffers.

Mark Mowers mowers at brsc.com
Wed Sep 15 13:09:29 EDT 2021


Issue:
string appears empty on the the gRPC client side of the send.

proto 3 file definition:
message XMLReportRequestParams { }
message XMLReportReply {
  string xml_string = 1;
}

service XMLReport {
  rpc GetXMLReport(XMLReportRequestParams) returns (stream XMLReportReply);
}

>From the CodeSynthesis, xsd cpp files, we have a structure called LOBType that gets populated with data.  LOB is the definition that takes the LOBType to serialize it to ostringstream.

Code in cpp server to create the XSD object and convert it to xml string:

somname::v2::LOBType lobType (l_id);
.... // lobType is populated with data types
  XSDErrorHandler errHandler;   // My own generic error handler
  ::xml_schema::flags flags = 0;
  xml_schema::namespace_infomap map;
  map["aa"].schema = xmlObjs_xsd;  // file schema name
  map["aa"].name   = m_xml_xsd_schema;  // path to file schema

  std::ostringstream ostrm;

  // format the LOB xml
  somname::v2::LOB (ostrm, lobType, errHandler, map, "UTF-8");

  std::string xmlString = std::move (ostrm.str());

  return xmlString;


This string is then inserted into the XMLReportReply and then it is written out to the gRPC so the client can receive it.

On the client side, the string is empty, no xml inside.

Any thoughts?   Am I doing the format of the xml string properly?

Thanks.
Mark Mowers
BRSC




More information about the xsd-users mailing list