UString USOAPEncoder::encodeMethod(URPCMethod& method, const UString& nsName) // namespace qualified element information { U_TRACE(0, "USOAPEncoder::encodeMethod(%p,%V)", &method, nsName.rep) method.encode(); // Encode the method by virtual method... if (method.hasFailed()) U_RETURN_STRING(encodedValue); uint32_t num_arg = arg.size(); if (num_arg > 1) encodedValue = arg.join(0, 0); else if (num_arg == 1) encodedValue = arg[0]; else encodedValue.setEmpty(); UString methodName = method.getMethodName(), headerContents = method.getHeaderContent(); if (bIsResponse) (void) methodName.append(U_CONSTANT_TO_PARAM("Response")); buffer.setBuffer(400U + (nsName.size() * 4) + (methodName.size() * 2) + encodedValue.size() + headerContents.size()); buffer.snprintf("<?xml version='1.0' ?>" "<env:Envelope xmlns:env=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" "<env:Header>%v</env:Header>" "<env:Body>" "<%v:%v env:encodingStyle=\"http://www.w3.org/2003/05/soap-encoding\" xmlns:%v=\"%v\">%v</%v:%v>" "</env:Body>" "</env:Envelope>", headerContents.rep, nsName.rep, methodName.rep, nsName.rep, nsName.rep, encodedValue.rep, nsName.rep, methodName.rep); U_RETURN_STRING(buffer); }
UString USOAPEncoder::encodeMethod(URPCMethod& method, const UString& nsName) // namespace qualified element information { U_TRACE(0, "USOAPEncoder::encodeMethod(%p,%.*S)", &method, U_STRING_TO_TRACE(nsName)) method.encode(); // Encode the method by virtual method... if (method.hasFailed()) U_RETURN_STRING(encodedValue); uint32_t num_arg = arg.size(); if (num_arg > 1) encodedValue = arg.join(0, 0); else if (num_arg == 1) encodedValue = arg[0]; else encodedValue.setEmpty(); UString methodName = method.getMethodName(), headerContents = method.getHeaderContent(); if (bIsResponse) (void) methodName.append(U_CONSTANT_TO_PARAM("Response")); uint32_t sz_nsName = nsName.size(), sz_methodName = methodName.size(), sz_encodedValue = encodedValue.size(), sz_headerContents = headerContents.size(); const char* ptr_nsName = nsName.data(); const char* ptr_methodName = methodName.data(); const char* ptr_encodedValue = encodedValue.data(); const char* ptr_headerContents = headerContents.data(); buffer.setBuffer(400U + (sz_nsName * 4) + (sz_methodName * 2) + sz_encodedValue + sz_headerContents); buffer.snprintf("<?xml version='1.0' ?>" "<env:Envelope xmlns:env=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" "<env:Header>%.*s</env:Header>" "<env:Body>" "<%.*s:%.*s env:encodingStyle=\"http://www.w3.org/2003/05/soap-encoding\" xmlns:%.*s=\"%.*s\">%.*s</%.*s:%.*s>" "</env:Body>" "</env:Envelope>", sz_headerContents, ptr_headerContents, sz_nsName, ptr_nsName, sz_methodName, ptr_methodName, sz_nsName, ptr_nsName, sz_nsName, ptr_nsName, sz_encodedValue, ptr_encodedValue, sz_nsName, ptr_nsName, sz_methodName, ptr_methodName); U_RETURN_STRING(buffer); }
UString URPCEncoder::encodeMethod(URPCMethod& method, const UString& nsName) // namespace qualified element information { U_TRACE(0, "URPCEncoder::encodeMethod(%p,%.*S)", &method, U_STRING_TO_TRACE(nsName)) encodedValue.setEmpty(); method.encode(); // Encode the method by virtual method... if (method.hasFailed() == false && bIsResponse == false) { UStringExt::buildTokenVector(method.getMethodName().data(), arg, encodedValue); } U_RETURN_STRING(encodedValue); }
URPCMethod* URPCObject::find(const UString& methodName) { U_TRACE(0, "URPCObject::find(%V)", methodName.rep) URPCMethod* method; uint32_t n = methodList.size(); // Iterate over the list of methods of the object for (uint32_t i = 0; i < n; ++i) { method = methodList[i]; if (methodName == method->getMethodName()) U_RETURN_POINTER(method, URPCMethod); } U_RETURN_POINTER(0, URPCMethod); }
UString URPCObject::processMessage(URPCEnvelope& envelope, bool& bContainsFault) { U_TRACE(0, "URPCObject::processMessage(%p,%p)", &envelope, &bContainsFault) U_INTERNAL_ASSERT_POINTER(URPCMethod::encoder) UString retval; // Iterate over the list of methods URPCMethod* method = find(envelope.getMethodName()); if (method == 0) { // Return object not found error. This would be a Client fault setFailed(); URPCMethod::pFault->setFaultReason(U_CONSTANT_TO_PARAM("The requested method does not exist on this server")); bContainsFault = true; retval = URPCMethod::encoder->encodeFault(URPCMethod::pFault); } else { UString ns = envelope.getNsName(); U_INTERNAL_DUMP("envelope.nsName = %V", ns.rep) // check the name of namespace qualified element information (gSOAP) if (ns.empty()) ns = method->getNamespaces(); if (ns.empty()) ns = *UString::str_ns; bContainsFault = (method->execute(envelope) == false); retval = URPCMethod::encoder->encodeMethodResponse(*method, ns); } U_RETURN_STRING(retval); }