Пример #1
0
/*
Code used for generating stubs:

int ns1__executeCommand(char* command, char** result);
*/
int ns1__executeCommand(soap* soap, char* command, char** result)
{
    // security check
    if (!soap->userid || !soap->passwd)
    {
        DEBUG_LOG("MaNGOSsoap: Client didn't provide login information");
        return 401;
    }

    uint32 accountId = sAccountMgr.GetId(soap->userid);
    if(!accountId)
    {
        DEBUG_LOG("MaNGOSsoap: Client used invalid username '%s'", soap->userid);
        return 401;
    }

    if(!sAccountMgr.CheckPassword(accountId, soap->passwd))
    {
        DEBUG_LOG("MaNGOSsoap: invalid password for account '%s'", soap->userid);
        return 401;
    }

    if(sAccountMgr.GetSecurity(accountId) < SECURITY_ADMINISTRATOR)
    {
        DEBUG_LOG("MaNGOSsoap: %s's gmlevel is too low", soap->userid);
        return 403;
    }

    if(!command || !*command)
        return soap_sender_fault(soap, "Command mustn't be empty", "The supplied command was an empty string");

    DEBUG_LOG("MaNGOSsoap: got command '%s'", command);
    SOAPCommand connection;

    // commands are executed in the world thread. We have to wait for them to be completed
    {
        // CliCommandHolder will be deleted from world, accessing after queueing is NOT save
        CliCommandHolder* cmd = new CliCommandHolder(accountId, SECURITY_CONSOLE, &connection, command, &SOAPCommand::print, &SOAPCommand::commandFinished);
        sWorld.QueueCliCommand(cmd);
    }

    // wait for callback to complete command

    int acc = connection.pendingCommands.acquire();
    if(acc)
    {
        sLog.outError("MaNGOSsoap: Error while acquiring lock, acc = %i, errno = %u", acc, errno);
    }

    // alright, command finished

    char* printBuffer = soap_strdup(soap, connection.m_printBuffer.c_str());
    if(connection.hasCommandSucceeded())
    {
        *result = printBuffer;
        return SOAP_OK;
    }
    else
        return soap_sender_fault(soap, printBuffer, printBuffer);
}
Пример #2
0
/*
Code used for generating stubs:

int ns1__executeCommand(char* command, char** result);
*/
int ns1__executeCommand(soap* soap, char* command, char** result)
{
    // security check
    if (!soap->userid || !soap->passwd)
    {
        TC_LOG_INFO("network.soap", "Client didn't provide login information");
        return 401;
    }

    uint32 accountId = AccountMgr::GetId(soap->userid);
    if (!accountId)
    {
        TC_LOG_INFO("network.soap", "Client used invalid username '%s'", soap->userid);
        return 401;
    }

    if (!AccountMgr::CheckPassword(accountId, soap->passwd))
    {
        TC_LOG_INFO("network.soap", "Invalid password for account '%s'", soap->userid);
        return 401;
    }

    if (AccountMgr::GetSecurity(accountId) < SEC_ADMINISTRATOR)
    {
        TC_LOG_INFO("network.soap", "%s's gmlevel is too low", soap->userid);
        return 403;
    }

    if (!command || !*command)
        return soap_sender_fault(soap, "Command can not be empty", "The supplied command was an empty string");

    TC_LOG_INFO("network.soap", "Received command '%s'", command);
    SOAPCommand connection;

    // commands are executed in the world thread. We have to wait for them to be completed
    {
        // CliCommandHolder will be deleted from world, accessing after queueing is NOT save
        CliCommandHolder* cmd = new CliCommandHolder(&connection, command, &SOAPCommand::print, &SOAPCommand::commandFinished);
        sWorld->QueueCliCommand(cmd);
    }

    // wait for callback to complete command

    int acc = connection.pendingCommands.acquire();
    if (acc)
        TC_LOG_ERROR("network.soap", "Error while acquiring lock, acc = %i, errno = %u", acc, errno);

    // alright, command finished

    char* printBuffer = soap_strdup(soap, connection.m_printBuffer.c_str());
    if (connection.hasCommandSucceeded())
    {
        *result = printBuffer;
        return SOAP_OK;
    }
    else
        return soap_sender_fault(soap, printBuffer, printBuffer);
}
Пример #3
0
int ns__getImage(struct soap *soap, char *name, ns__Data& image)
{

	if (!name)
		return soap_sender_fault(soap, "Name required", NULL);
	if (getdata(soap, name, image))
		return soap_sender_fault(soap, "Access denied", NULL);
	image.type = (char*)"image/jpeg";
	image.options = soap_dime_option(soap, 0, name);
	return SOAP_OK;
}
Пример #4
0
int check_header(struct soap *soap)
{ /* MUST have received a SOAP Header */
  if (!soap->header)
    return soap_sender_fault(soap, "No SOAP header", NULL);
  /* ... with a Message ID */
  if (!soap->header->wsa__MessageID)
    return soap_sender_fault(soap, "No WS-Addressing MessageID", NULL);
  soap->header->wsa__RelatesTo = (struct wsa__Relationship*)soap_malloc(soap, sizeof(struct wsa__Relationship));
  soap_default_wsa__Relationship(soap, soap->header->wsa__RelatesTo);
  soap->header->wsa__RelatesTo->__item = soap->header->wsa__MessageID;
  return SOAP_OK;
}
Пример #5
0
//**********************************************************************************
// ns1__createTextImage
//**********************************************************************************
int ns1__createTextImage(struct soap* soap,
						 unsigned char colorDepth,
						 char *imageMimeType,
						 wchar_t *text,
						 struct ns1__HtiFont* font,
						 struct ns1__HtiRGB    fgColor,
						 struct ns1__HtiRGB    bgColor,
						 struct ns1__captureScreenResponse &r)
{
	// check text & imageMimeType parameters
	if ( check_mandatory_wcstring_parameter( soap, text, "text" ) ||
		 check_mandatory_string_parameter( soap, imageMimeType, "imageMimeType" ) )
		return SOAP_FAULT;
	else if ( wcslen( text ) > 0xff )
	{
		soap->error = soap_sender_fault(soap, "HtiGateway", "Text too long");
		return SOAP_FAULT;
	}

	// check font parameter
	if ( font == NULL )
	{
		soap->error = soap_sender_fault( soap, "HtiGateway", "No font parameter" );
		return SOAP_FAULT;
	}
	if ( check_mandatory_wcstring_parameter( soap, font->fontName, "fontName" ) )
		return SOAP_FAULT;

	// construct and send the message
	HtiMsgHelper msg( soap, HTI_UID, CMD_TEXT_IMG_U );
	msg.AddByte( colorDepth );
	msg.AddStringWithLengthByte( imageMimeType );
	msg.AddWCStringWithLengthByte( text );
	AddHtiFont( msg, *font );
	msg.AddByte( fgColor.red ); // note little endian encoding
	msg.AddByte( fgColor.green );
	msg.AddByte( fgColor.blue );
	msg.AddByte( 0x00 );
	msg.AddByte( bgColor.red );
	msg.AddByte( bgColor.green );
	msg.AddByte( bgColor.blue );
	msg.AddByte( 0x00 );
	if ( msg.SendReceiveMsg( g_ScreenHtiTimeoutImage ) )
		return SOAP_FAULT;

	// get response
	return SetScreenCaptureAttachment( soap, msg.GetMsgBody(), msg.GetMsgLen(),
		CMD_TEXT_IMG_U, imageMimeType ,r );
}
Пример #6
0
/*
 * This method is used to forward soap request to correct SOAPHandler
 * Correct SOAPHandler is found by soap action
 */
bool HtiDispatcher::DispatchSoapServe(struct soap* soapEnv)
{
	Util::Debug("HtiDispatcher::DispatchSoapServe()");
/*	
	_CrtMemState localMem;
	_CrtMemCheckpoint( &localMem );
*/
	soap_begin( soapEnv );
	if (soap_begin_recv(soapEnv))
	{
		soap_set_namespaces( soapEnv, namespaces);
		soap_send_fault(soapEnv);
		return false;
	}

	if ( !(soapEnv->action) )
	{
		//Util::Error("soapAction is missing");
		soap_set_namespaces( soapEnv, namespaces);
		soapEnv->error = soap_sender_fault(soapEnv, "soapAction is missing", NULL); 
		soap_send_fault(soapEnv);
		return false;
	}
/*
	//_RPT0(_CRT_WARN, "!!!!!!!!!!!!!!!! Local Objects !!!!!!!!!!!!!!!!\n");

	_CrtMemDumpAllObjectsSince( &localMem );
	//_RPT1(_CRT_WARN, "action address %x\n", soapEnv->action);
*/
	htiSoapActionHashMap::const_iterator it;
	it = m_SoapHandlers.find( soapEnv->action );
	if ( it != m_SoapHandlers.end() )
	{
		return (it->second)->ServeSoap( soapEnv );
	}
	else
	{
		//Util::Error("soapAction is unknown:");
		//Util::Error(soapEnv->action);
		//soapEnv->error = SOAP_NO_METHOD;
		soap_set_namespaces( soapEnv, namespaces);
		soapEnv->error = soap_sender_fault(soapEnv, "No plugin found", "no plugin found for requested service in actionSOAP header field"); 
		soap_send_fault(soapEnv);
		return false;
	}

	Util::Debug("HtiDispatcher::DispatchSoapServe() OK");
}
Пример #7
0
int ns1__sub(struct soap *soap, double a, double b, double *result)
{ const char *username = soap_wsse_get_Username(soap);
  if (username)
    fprintf(stderr, "Hello %s, want to subtract %g - %g = ?\n", username, a, b);
  if (soap_wsse_verify_Timestamp(soap)
   || soap_wsse_verify_Password(soap, "userPass"))
  { soap_wsse_delete_Security(soap);
    return soap->error;
  }
  if (soap_wsse_verify_element(soap, "http://www.genivia.com/schemas/wssetest.xsd", "sub") == 0)
  { soap_wsse_delete_Security(soap);
    return soap_sender_fault(soap, "Service operation not signed", NULL);
  }
  soap_wsse_delete_Security(soap);
  /* In this case we leave out the timestamp, which is the sender's
   * responsibility to add. The receiver only complains if the timestamp is out
   * of date, not that it is absent. */
  if (hmac)
  { soap_wsse_sign_body(soap, SOAP_SMD_HMAC_SHA1, hmac_key, sizeof(hmac_key));
    /* WS-SecureConversation contect token */
    soap_wsse_add_SecurityContextToken(soap, "SCT", contextId);
  }
  else
  { if (nokey)
      soap_wsse_add_KeyInfo_KeyName(soap, "MyKey");
    else
    { soap_wsse_add_BinarySecurityTokenX509(soap, "X509Token", cert);
      soap_wsse_add_KeyInfo_SecurityTokenReferenceX509(soap, "#X509Token");
    }
    soap_wsse_sign_body(soap, SOAP_SMD_SIGN_RSA_SHA256, rsa_privk, 0);
  }
  *result = a - b;
  return SOAP_OK;
}
Пример #8
0
void *mime_server_write_open(struct soap *soap, void *unused_handle,
		const char *id, const char *type, const char *description,
		enum soap_mime_encoding encoding) { /* Note: the 'unused_handle' is always NULL */
	/* Return NULL without setting soap->error if we don't want to use the streaming callback for this DIME attachment */
	const char *file;
	struct mime_server_handle *handle = soap_malloc(soap,
			sizeof(struct mime_server_handle));
	if (!handle) {
		soap->error = SOAP_EOM;
		return NULL;
	}
	/* Create a new file */
	file = tempnam(TMPDIR, "data");
	/* The file name is also the key */
	handle->key = soap_strdup(soap, file);
	handle->fd = fopen(file, "wb");
	free((void*) file);
	if (!handle->fd) {
		soap->error = soap_sender_fault(soap,
				"Cannot save data to file", handle->key);
		soap->errnum = errno; /* get reason */
		return NULL;
	}
	fprintf(stderr, "Saving file %s type %s\n", handle->key,
			type ? type : "");
	return (void*) handle;
}
int ns1__luinv(struct soap *soap, matrix *a, matrix *b)
{ vector col(soap);
  ivector indx(soap);
  double d;
  int i, j, k, n;
  if (ludcmp(soap, *a, indx, d))
    return soap_sender_fault(soap, "Singular matrix in routine ludcmp", NULL);
  n = a->size();
  col.resize(n);
  b->resize(n, n);
  for (j = 1; j <= n; j++)
  { for (i = 1; i <= n; i++)
      col[i] = 0.0;
    col[j] = 1.0;
    lubksb(*a, indx, col);
    for (i = 1; i <= n; i++)
      (*b)[i][j] = col[i];
  }
  for (i = 1; i <= n; i++)
  { for (j = 1; j <= n; j++)
      if (fabs((*b)[i][j]) > 1.0e-15)
        break;
    for (k = n; k > j; k--)
      if (fabs((*b)[i][k]) > 1.0e-15)
        break;
    (*b)[i].resize(j, k);
  }
  return SOAP_OK;
}
Пример #10
0
int ns1__mul(struct soap *soap, double a, double b, double *result)
{ const char *username = soap_wsse_get_Username(soap);
  if (username)
    fprintf(stderr, "Hello %s, want to multiply %g * %g = ?\n", username, a, b);
  if (soap_wsse_verify_Timestamp(soap)
   || soap_wsse_verify_Password(soap, "userPass"))
  { soap_wsse_delete_Security(soap);
    return soap->error;
  }
  if (soap_wsse_verify_element(soap, "http://www.genivia.com/schemas/wssetest.xsd", "mul") == 0)
  { soap_wsse_delete_Security(soap);
    return soap_sender_fault(soap, "Service operation not signed", NULL);
  }
  soap_wsse_delete_Security(soap);
  soap_wsse_add_Timestamp(soap, "Time", 10);	/* lifetime of 10 seconds */
  /* In this case we leave out the server name and password. Because the
   * client receiver requires the presence of authentication information, the
   * client will reject the response. */
  if (hmac)
  { soap_wsse_sign_body(soap, SOAP_SMD_HMAC_SHA1, hmac_key, sizeof(hmac_key));
    /* WS-SecureConversation contect token */
    soap_wsse_add_SecurityContextToken(soap, "SCT", contextId);
  }
  else
  { if (nokey)
      soap_wsse_add_KeyInfo_KeyName(soap, "MyKey");
    else
    { soap_wsse_add_BinarySecurityTokenX509(soap, "X509Token", cert);
      soap_wsse_add_KeyInfo_SecurityTokenReferenceX509(soap, "#X509Token");
    }
    soap_wsse_sign_body(soap, SOAP_SMD_SIGN_RSA_SHA256, rsa_privk, 0);
  }
  *result = a * b;
  return SOAP_OK;
}
Пример #11
0
int ns__echoString(struct soap *soap, char *str, char **res)
{ /* Get Header info and setup response Header */
  if (check_header(soap))
  { printf("Malformed header\n");
    return SOAP_FAULT; /* there was a problem */
  }

  /* If message with MessageID already received, ignore it */
  if (check_received(soap->header->wsa__MessageID))
  { printf("Request message %s already received\n", soap->header->wsa__MessageID);
    return SOAP_STOP;
  }

  printf("Request message %s accepted\n", soap->header->wsa__MessageID);

  /* Check ReplyTo has Address */
  if (!soap->header->wsa__ReplyTo || !soap->header->wsa__ReplyTo->Address)
    return soap_sender_fault(soap, "No WS-Addressing ReplyTo address", NULL);
  /* Copy Header info into response Header */
  soap->header->wsa__To = soap->header->wsa__ReplyTo->Address;

  /* Add info to response Header */
  soap->header->wsa__MessageID = soap_strdup(soap, soap_int2s(soap, id_count++));
  soap->header->wsa__Action = "http://genivia.com/udp/echoStringResponse";

  /* Copy request string into response string */
  printf("Response message %s returned\n", soap->header->wsa__MessageID);
  *res = str;

  return SOAP_OK;
}
Пример #12
0
int ns1__ludcmp(struct soap *soap, matrix *a, struct ns1__ludcmpResponse &result)
{ result.a = a;
  result.i = soap_new_ivector(soap, -1);
  if (ludcmp(soap, *result.a, *result.i, result.d))
    return soap_sender_fault(soap, "Singular matrix in routine ludcmp", NULL);
  return SOAP_OK;
}
Пример #13
0
int ns1__ludet(struct soap *soap, matrix *a, double &d)
{ ivector indx(soap);
  if (ludcmp(soap, *a, indx, d))
    return soap_sender_fault(soap, "Singular matrix in routine ludcmp", NULL);
  for (int i = 1; i <= a->__size; i++)
    d *= (*a)[i][i];
  return SOAP_OK;
}
Пример #14
0
int ocalc__sqrt(struct soap *soap, double a, double *result)
{   if (a >= 0)
    {   *result = sqrt(a);
        return SOAP_OK;
    }
    else
        return soap_sender_fault(soap, "Square root of negative value", "I can only take the square root of non-negative values");
}
Пример #15
0
int ns1__lusol(struct soap *soap, matrix *a, vector *b, vector *x)
{ ivector indx(soap);
  double d;
  if (ludcmp(soap, *a, indx, d))
    return soap_sender_fault(soap, "Singular matrix in routine ludcmp", NULL);
  lubksb(*a, indx, *b);
  *x = *b;
  return SOAP_OK;
}
Пример #16
0
int ns2__pow(struct soap *soap, double a, double b, double *result)
{ *result = pow(a, b);
  if (soap_errno == EDOM)	/* soap_errno is like errno, but compatible with Win32 */
  { char *s = (char*)soap_malloc(soap, 1024);
    sprintf(s, "Can't take the power of %f to %f", a, b);
    sprintf(s, "<error xmlns=\"http://tempuri.org/\">Can't take power of %f to %f</error>", a, b);
    return soap_sender_fault(soap, "Power function domain error", s);
  }
  return SOAP_OK;
} 
Пример #17
0
int ns2__div(struct soap *soap, double a, double b, double *result)
{ if (b)
    *result = a / b;
  else
  { char *s = (char*)soap_malloc(soap, 1024);
    sprintf(s, "<error xmlns=\"http://tempuri.org/\">Can't divide %f by %f</error>", a, b);
    return soap_sender_fault(soap, "Division by zero", s);
  }
  return SOAP_OK;
} 
Пример #18
0
int ns__getData(struct soap *soap, arrayOfName *names, arrayOfData *data)
{

	DBG("\n");
	// gSOAP switches to SOAP_IO_STORE when SOAP_IO_CHUNK (HTTP chunking) is not supported by the client.
	// Since it is undesirable to use SOAP_IO_STORE, we reset it to SOAP_IO_BUFFER
	if ((soap->omode & SOAP_IO) == SOAP_IO_STORE)
		soap->omode = (soap->omode & ~SOAP_IO) | SOAP_IO_BUFFER;
	if (!names)
		return soap_sender_fault(soap, "Names required", NULL);
	data->resize(names->size());
	for (int i = 0; i < names->__size; i++)
	{ if (!(*names)[i])
			return soap_sender_fault(soap, "Name required", NULL);
		if (getdata(soap, (*names)[i], (*data)[i]))
			return soap_sender_fault(soap, "Access denied", NULL);
	}
	return SOAP_OK;
}
Пример #19
0
int ns1__lusols(struct soap *soap, matrix *a, matrix *b, matrix *x)
{ ivector indx(soap);
  double d;
  if (ludcmp(soap, *a, indx, d))
    return soap_sender_fault(soap, "Singular matrix in routine ludcmp", NULL);
  for (int i = 1; i <= b->size(); i++)
    lubksb(*a, indx, (*b)[i]);
  *x = *b;
  return SOAP_OK;
}
Пример #20
0
int m__EchoTestMultiple(struct soap *soap, struct x__WrapperType *x__EchoTest, struct m__EchoTestMultipleResponse *response)
{ int i;
  if (!x__EchoTest)
    return soap_sender_fault(soap, "No data", NULL);
  /* allocate response */
  response->x__EchoTest = (struct x__WrapperType*)soap_malloc(soap, sizeof(struct x__WrapperType));
  if (!response->x__EchoTest)
    return SOAP_EOM;
  response->x__EchoTest->__size = x__EchoTest->__size;
  response->x__EchoTest->Data = (struct x__DataType*)soap_malloc(soap, sizeof(struct x__DataType) * x__EchoTest->__size);
  if (!response->x__EchoTest->Data)
    return SOAP_EOM;
  /* copy data into response, switching from base64 to MTOM and vice versa */
  for (i = 0; i < x__EchoTest->__size; ++i)
  { switch (x__EchoTest->Data[i].__union)
    { case SOAP_UNION_x__data_xop__Include:
        /* convert MTOM attachment to base64Binary */
        response->x__EchoTest->Data[i].__union = SOAP_UNION_x__data_base64;
        response->x__EchoTest->Data[i].choice.base64.__ptr = x__EchoTest->Data[i].choice.xop__Include.__ptr;
        response->x__EchoTest->Data[i].choice.base64.__size = x__EchoTest->Data[i].choice.xop__Include.__size;
        response->x__EchoTest->Data[i].xmime5__contentType = x__EchoTest->Data[i].choice.xop__Include.type;
        break;
      case SOAP_UNION_x__data_base64:
        /* convert base64Binary to MTOM attachment */
        response->x__EchoTest->Data[i].__union = SOAP_UNION_x__data_xop__Include;
        response->x__EchoTest->Data[i].choice.xop__Include.__ptr = x__EchoTest->Data[i].choice.base64.__ptr;
        response->x__EchoTest->Data[i].choice.xop__Include.__size = x__EchoTest->Data[i].choice.base64.__size;
        response->x__EchoTest->Data[i].choice.xop__Include.id = NULL;
        response->x__EchoTest->Data[i].choice.xop__Include.type = x__EchoTest->Data[i].xmime5__contentType;
        response->x__EchoTest->Data[i].choice.xop__Include.options = NULL;
        response->x__EchoTest->Data[i].xmime5__contentType = x__EchoTest->Data[i].xmime5__contentType;
#ifdef WITH_NOIDREF
        /* compiling with WITH_NOIDREF removes auto-detection of attachments */
        soap_set_mime(soap, NULL, NULL); /* so we explicitly set MIME attachments */
#endif
        break;
      default:
        return soap_sender_fault(soap, "Wrong data format", NULL);
    }
  }
  return SOAP_OK;
}
Пример #21
0
int m__GetData(struct soap *soap, struct x__Keys *keys, struct m__GetDataResponse *response)
{ int i;
  if ((soap->omode & SOAP_IO) == SOAP_IO_STORE)
    soap->omode = (soap->omode & ~SOAP_IO) | SOAP_IO_BUFFER;
  if (!keys)
    return soap_sender_fault(soap, "No keys", NULL);
  /* Set up array of attachments to return */
  response->x__data.__size = keys->__size;
  response->x__data.item = soap_malloc(soap, keys->__size*sizeof(struct x__Data));
  for (i = 0; i < keys->__size; ++i)
    open_data(soap, keys->key[i], &response->x__data.item[i]);
  return SOAP_OK;
}
Пример #22
0
int ns1__div(struct soap *soap, double a, double b, double *result)
{ const char *username = soap_wsse_get_Username(soap);
  if (username)
    fprintf(stderr, "Hello %s, want to divide %g / %g = ?\n", username, a, b);
  if (soap_wsse_verify_Timestamp(soap)
   || soap_wsse_verify_Password(soap, "userPass"))
  { soap_wsse_delete_Security(soap);
    return soap->error;
  }
  if (soap_wsse_verify_element(soap, "http://www.genivia.com/schemas/wssetest.xsd", "div") == 0)
  { soap_wsse_delete_Security(soap);
    return soap_sender_fault(soap, "Service operation not signed", NULL);
  }
  soap_wsse_delete_Security(soap);
  soap_wsse_add_Timestamp(soap, "Time", 10);	/* lifetime of 10 seconds */
  soap_wsse_add_UsernameTokenDigest(soap, "User", "server", "serverPass");
  /* In this case we leave out the signature and the receiver will reject this unsigned message. */
  if (b == 0.0)
    return soap_sender_fault(soap, "Division by zero", NULL);
  *result = a / b;
  return SOAP_OK;
}
Пример #23
0
int m__EchoTestSingle(struct soap *soap, struct x__DataType *data, struct m__EchoTestSingleResponse *response)
{ if (!data)
  { /* To return a fault in an MTOM attachment:
       soap_set_mode(soap, SOAP_ENC_MTOM | SOAP_ENC_MIME); */
    return soap_sender_fault(soap, "No data", NULL);
  }
  /* allocate response */
  response->x__Data = (struct x__DataType*)soap_malloc(soap, sizeof(struct x__DataType));
  if (!response->x__Data)
    return SOAP_EOM;
  /* copy data into response, switching from base64 to MTOM and vice versa */
  switch (data->__union)
  { case SOAP_UNION_x__data_xop__Include:
      /* convert MTOM attachment to base64Binary */
      response->x__Data->__union = SOAP_UNION_x__data_base64;
      response->x__Data->choice.base64.__ptr = data->choice.xop__Include.__ptr;
      response->x__Data->choice.base64.__size = data->choice.xop__Include.__size;
      response->x__Data->xmime5__contentType = data->choice.xop__Include.type;
      break;
    case SOAP_UNION_x__data_base64:
      /* convert base64Binary to MTOM attachment */
      response->x__Data->__union = SOAP_UNION_x__data_xop__Include;
      response->x__Data->choice.xop__Include.__ptr = data->choice.base64.__ptr;
      response->x__Data->choice.xop__Include.__size = data->choice.base64.__size;
      response->x__Data->choice.xop__Include.id = NULL;
      response->x__Data->choice.xop__Include.type = data->xmime5__contentType;
      response->x__Data->choice.xop__Include.options = NULL;
      response->x__Data->xmime5__contentType = data->xmime5__contentType;
#ifdef WITH_NOIDREF
      /* compiling with WITH_NOIDREF removes auto-detection of attachments */
      soap_set_mime(soap, NULL, NULL); /* so we explicitly set MIME attachments */
#endif
      break;
    default:
      return soap_sender_fault(soap, "Wrong data format", NULL);
  }
  return SOAP_OK;
}
Пример #24
0
static int http_md5_disconnect(struct soap *soap)
{ struct http_md5_data *data = (struct http_md5_data*)soap_lookup_plugin(soap, http_md5_id);
  char digest[16];
  if (!data)
    return SOAP_PLUGIN_ERROR;
  md5_handler(soap, &data->context, MD5_FINAL, digest, 0);
  soap->fpreparerecv = data->fpreparerecv;
  soap->fdisconnect = data->fdisconnect;
  if (memcmp(digest, data->digest, 16))
    return soap_sender_fault(soap, "MD5 digest mismatch: message corrupted", NULL);
  if (soap->fdisconnect)
    return soap->fdisconnect(soap);
  return SOAP_OK;
}
Пример #25
0
int BasicHttpBinding_USCOREICalculatorService::Add(_mssamm__Add *Add, _mssamm__AddResponse *AddResponse)
{
  double *res = (double*)soap_malloc(soap, sizeof(double));

  if (chk_security(soap))
    return soap->error;

  if (Add && Add->n1 && Add->n2)
    *res = *Add->n1 + *Add->n2;
  else
    return soap_sender_fault(soap, "Invalid data", NULL);
  AddResponse->AddResult = res;

  return set_srv_security(soap);
}
Пример #26
0
int BasicHttpBinding_USCOREICalculatorService::Subtract(_mssamm__Subtract *Subtract, _mssamm__SubtractResponse *SubtractResponse)
{
  double *res = (double*)soap_malloc(soap, sizeof(double));

  if (chk_security(soap))
    return soap->error;

  if (Subtract && Subtract->n1 && Subtract->n2)
    *res = *Subtract->n1 - *Subtract->n2;
  else
    return soap_sender_fault(soap, "Invalid data", NULL);
  SubtractResponse->SubtractResult = res;

  return set_srv_security(soap);
}
Пример #27
0
int BasicHttpBinding_USCOREICalculatorService::Multiply(_mssamm__Multiply *Multiply, _mssamm__MultiplyResponse *MultiplyResponse)
{
  double *res = (double*)soap_malloc(soap, sizeof(double));

  if (chk_security(soap))
    return soap->error;

  if (Multiply && Multiply->n1 && Multiply->n2)
    *res = *Multiply->n1 * *Multiply->n2;
  else
    return soap_sender_fault(soap, "Invalid data", NULL);
  MultiplyResponse->MultiplyResult = res;

  return set_srv_security(soap);
}
Пример #28
0
int BasicHttpBinding_USCOREICalculatorService::Divide(_mssamm__Divide *Divide, _mssamm__DivideResponse *DivideResponse)
{
  double *res = (double*)soap_malloc(soap, sizeof(double));

  if (chk_security(soap))
    return soap->error;

  if (Divide && Divide->n1 && Divide->n2 && *Divide->n2 != 0.0)
    *res = *Divide->n1 / *Divide->n2;
  else
    return soap_sender_fault(soap, "Invalid data", NULL);
  DivideResponse->DivideResult = res;

  return set_srv_security(soap);
}
Пример #29
0
int m__PutData(struct soap *soap, struct x__DataSet *data, struct m__PutDataResponse *response)
{ int i;
  /* This operation is called AFTER the streaming MIME attachment callbacks
     handled the data.  gSOAP switches to SOAP_IO_STORE when SOAP_IO_CHUNK
     (HTTP chunking) is not supported by the client. Since it is undesirable to
     use SOAP_IO_STORE to buffer the entire message, we reset it to the default
     SOAP_IO_BUFFER for socket connections.
  */
  if ((soap->omode & SOAP_IO) == SOAP_IO_STORE)
    soap->omode = (soap->omode & ~SOAP_IO) | SOAP_IO_BUFFER;
  if (!data)
    return soap_sender_fault(soap, "No data", NULL);
  /* Set up array of keys to return a key for each data item saved */
  response->x__keys.__size = data->__size;
  response->x__keys.key = soap_malloc(soap, data->__size*sizeof(char**));
  /* Each key is stored in the mime_server_handle object, set by the callbacks and accessible through the data __ptr */
  for (i = 0; i < data->__size; i++)
  { if (data->item[i].xop__Include.__ptr)
    { const char *key = ((struct mime_server_handle*)(data->item[i].xop__Include.__ptr))->key;
      const char *s;
      if (!key)
        return soap_sender_fault(soap, "Missing name", NULL);
      s = strrchr(key, '/');
      if (!s)
        s = strrchr(key, '\\');
      if (!s)
        s = key;
      else
        s++;
      response->x__keys.key[i] = soap_strdup(soap, s);
    }
    else
      response->x__keys.key[i] = "-";
  }
  return SOAP_OK;
}
    void checkHeader(const std::string & faultMessage)
    {
        // check WSA
        if (soap_header() == NULL) {
            if (soap_sender_fault(RemoteDiscoveryBindingProxy::soap, "checkHeader", faultMessage.c_str()) != 0)
                throw SoapException(RemoteDiscoveryBindingProxy::soap);
        }

//        if (soap_header()->wsd__AppSequence != NULL) {
//            wsd__AppSequenceType * seq = soap_header()->wsd__AppSequence;
//            instanceId() = seq->InstanceId;
//            messageNumber() = seq->MessageNumber;
//            if (seq->SequenceId != NULL)
//                sequenceId() = *seq->SequenceId;
//        }
    }