小编ble*_*ter的帖子

如何使用成员资格/授权在Azure上启用WCF服务的流传输?

我已经撞墙了,已经把头发拉了一段时间了.基本上,我需要创建一个具有ASP.NET成员资格和授权提供程序的WCF服务,但是它需要允许传输byte []数组或Stream对象并将它们保存到Azure.该服务本身托管在Azure上.

我遇到的问题是WCF需要消息层安全性来交换客户端凭据.所以我有以下配置,它运作得很好:

<system.serviceModel>
  <behaviors>
    <serviceBehaviors>
      <behavior name="DefaultServiceBehavior">
        <serviceMetadata httpsGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="true" />
        <serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="SqlRoleProvider" />
          <serviceCredentials>
            <serviceCertificate x509FindType="FindBySubjectName" storeName="My" storeLocation="LocalMachine" findValue="SecureChannelCertificate" />
            <userNameAuthentication userNamePasswordValidationMode="MembershipProvider"  membershipProviderName="SqlMembershipProvider" />
         </serviceCredentials>
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <bindings>
    <wsHttpBinding>
      <binding name="SecureBinding" messageEncoding="Mtom">
        <security mode="Message">
          <message clientCredentialType="UserName" negotiateServiceCredential="true" establishSecurityContext="true" />
        </security>
      </binding>
    </wsHttpBinding>
  </bindings>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)

然后,需求发生了变化,现在我需要通过WCF服务将文件推送到Azure.无论我做什么,WCF都会因各种错误而尖叫我.

有谁知道如何配置服务,以便它可以使用身份验证/授权以及流媒体?

谢谢!

c# wcf wcf-binding azure wcf-security

1
推荐指数
1
解决办法
753
查看次数

使用指针到C中的结构内部的函数

只是为了s&g.我想在C中构建自己的库.我想让它遵循C#对象的概念,并意识到这样做的唯一方法是让基类型使用函数指针作为它们的成员.

好吧,我被卡住了,不知道为什么.以下是String基类型的示例:

#ifndef STRING_H
#define STRING_H

typedef struct _string
{
    char* Value;
    int Length;
    String* (*Trim)(String*, char);

} String;

String* String_Allocate(char* s);
String* Trim(String* s, char trimCharacter);

#endif  /* STRING_H */
Run Code Online (Sandbox Code Playgroud)

并实施:

String* Trim(String* s, char trimCharacter)
{
    int i=0;
    for(i=0; i<s->Length; i++)
    {
        if( s->Value[i] == trimCharacter )
        {
            char* newValue = (char *)malloc(sizeof(char) * (s->Length - 1));
            int j=1;

            for(j=1; j<s->Length; j++)
            {
                newValue[j] = s->Value[j];
            }

            s->Value = newValue;
        }
        else
        {
            break;
        }
    }

    s->Length = …
Run Code Online (Sandbox Code Playgroud)

c struct data-structures

1
推荐指数
1
解决办法
772
查看次数

如何比较c中的字符

我有一个小项目,我需要比较一个流的第一个字节.问题是该字节可以是0xe5或任何其他不可打印的字符,因此表示该特定数据是坏的(一次读取32位).我可以允许的有效字符是AZ,az,0-9,'.' 和空间.

目前的代码是:

FILE* fileDescriptor; //assume this is already open and coming as an input to this function.
char entry[33];

if( fread(entry, sizeof(unsigned char), 32, fileDescriptor) != 32 )
{
    return -1; //error occured
}

entry[32] = '\0';  //set the array to be a "true" cstring.

int firstByte = (int)entry[0];

if( firstByte == 0 ){
    return -1;    //the entire 32 bit chunk is empty.
}

if( (firstByte & 0xe5) == 229 ){       //denotes deleted.
    return -1;    //denotes deleted.
}
Run Code Online (Sandbox Code Playgroud)

所以问题在于,当我尝试执行以下操作时: …

c linux c-strings cstring standard-library

0
推荐指数
1
解决办法
1896
查看次数

c中未定义的引用...我做错了什么?

我有以下代码...这是投掷main.cpp:18: undefined reference to phrase_init()来自C#经验C有点烦人,特别是当试图找出问题所在:(任何想法或指针将不胜感激!

phrase.h:

#ifndef PHRASE_H
#define PHRASE_H

typedef struct
{
    char* Word1;
    char* Word2;
} Phrase;

Phrase* phrase_init(void);

#endif
Run Code Online (Sandbox Code Playgroud)

Phrase.c:

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>

#include "phrase.h"

Phrase* phrase_init()
{
    Phrase* phrase = (Phrase *)malloc(sizeof(Phrase));

    phrase->Word1 = (char *)malloc(sizeof(char));
    phrase->Word2 = (char *)malloc(sizeof(char));

    return phrase;
}
Run Code Online (Sandbox Code Playgroud)

main.c中

#include <cstdlib>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <cctype>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>

#include "phrase.h"

int main(int argc, char** argv) {

    char* …
Run Code Online (Sandbox Code Playgroud)

c++ linux g++

0
推荐指数
1
解决办法
1037
查看次数