Web服务REST:如何在参数中传递URL?

时间:2018-02-01 14:31:18

标签: .net rest wcf url parameters

我有一个WCF REST Web服务:

IService.vb:

/**
 * Returns {@code true} if the key resides inside secure hardware (e.g., Trusted Execution
 * Environment (TEE) or Secure Element (SE)). Key material of such keys is available in
 * plaintext only inside the secure hardware and is not exposed outside of it.
 */
public boolean isInsideSecureHardware() 
{
    return mInsideSecureHardware;
}

/**
 * Returns {@code true} if the requirement that this key can only be used if the user has been
 * authenticated is enforced by secure hardware (e.g., Trusted Execution Environment (TEE) or
 * Secure Element (SE)).
 *
 * @see #isUserAuthenticationRequired()
 */
public boolean isUserAuthenticationRequirementEnforcedBySecureHardware() 
{
    return mUserAuthenticationRequirementEnforcedBySecureHardware;
}

/**
 * Returns {@code true} if the key is authorized to be used only if the user has been
 * authenticated.
 *
 * <p>This authorization applies only to secret key and private key operations. Public key
 * operations are not restricted.
 *
 * @see #getUserAuthenticationValidityDurationSeconds()
 * @see KeyGenParameterSpec.Builder#setUserAuthenticationRequired(boolean)
 * @see KeyProtection.Builder#setUserAuthenticationRequired(boolean)
 */
public boolean isUserAuthenticationRequired() 
{
    return mUserAuthenticationRequired;
}

Service.svc.vb:

<Style x:Key="tbxStyle" TargetType="TextBox">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="TextBox">
                        <Grid>
                            <TextBox Text="{TemplateBinding Text}">
                                <TextBox.InputBindings>
                                    <KeyBinding Key="Enter" Command="{Binding SaveConfigCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=TextBox}}"/>
                                </TextBox.InputBindings>
                            </TextBox>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

<TextBox Text="{Binding SelectedItem}" Style="{StaticResource tbxStyle}">

我必须传入参数URL,例如

<OperationContract()>
<WebInvoke(Method:="Get", 
      UriTemplate:=:GetFileList/{DirectoryName},
      RequestFormat:=...Json
      ResponseFormat:=...Json
      BodyStyle:=...Wrapped)>
Function GetFileList(ByVal DirectoryName as String) As ArrayList()

localhost:49658 / Service.svc / GetFileList / C:\ Programs

首先它产生了一个错误“从客户端(:)检测到一个潜在危险的Request.Path值”所以在我添加的web.config文件中:

Public Function GetFileList(ByVal DirectoryName as String) As ArrayList() Implements IService.GetFileList
    Return "------ " & DirectoryName & " ---------"
End Function

和:

DirectoryName = "C: \ Programs"

它让我写&#34;:&#34;。但现在,它没有工作,我有一个错误:&#34;没有找到端点&#34;这是正常的,因为我正在使用&#34; \&#34;

那么,知道如何在参数中传递这个url地址吗?我听说过编码,但我不明白它是如何工作的,每次我去设置另一个URL(目录路径)。

谢谢, ELA

0 个答案:

没有答案