Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
什么';这个分派Scala的等价HttpClient Java代码是什么?_Java_Scala_Scala Dispatch - Fatal编程技术网

什么';这个分派Scala的等价HttpClient Java代码是什么?

什么';这个分派Scala的等价HttpClient Java代码是什么?,java,scala,scala-dispatch,Java,Scala,Scala Dispatch,更新-已解决:这是对AuthScope的误解。我明白了,基本上我是通过协议传递整个url的。”https://mysite.com我解决了这个问题,而不仅仅是“mysite.com” 这是对AuthScope的误解。我明白了,基本上我是通过协议传递整个url的。”https://mysite.com我解决了这个问题,而不仅仅是“mysite.com”。? import dispatch._ val h = new Http val req = url(url).as_!(username, pa

更新-已解决:这是对AuthScope的误解。我明白了,基本上我是通过协议传递整个url的。”https://mysite.com我解决了这个问题,而不仅仅是“mysite.com”

这是对AuthScope的误解。我明白了,基本上我是通过协议传递整个url的。”https://mysite.com我解决了这个问题,而不仅仅是“mysite.com”。

import dispatch._
val h = new Http
val req = url(url).as_!(username, password)
val handler = req << (payload, "application/xml") >:> identity
handler.apply { 
    case (200, _, Some(entity), _) => (200, Some(entity))
    case (status, _,_,_) => (status, None)
}
val response = h(handler)
public static void postService(Profile user, String subject, String body){
    Credentials credentials = new UsernamePasswordCredentials(userName, authToken);
    AuthScope authScope = new AuthScope(baseUrl, 80, AuthScope.ANY_REALM);
    HttpClient client = new HttpClient();
    PostMethod post = new PostMethod(baseUrl);

    client.getParams().setAuthenticationPreemptive(true);
    client.getState().setCredentials(authScope, credentials);

    String payload = makePayload(user, subject, body);
    RequestEntity entity = null;
    try{
        entity = new StringRequestEntity(payload, CONTENT_TYPE, null);
    } catch(UnsupportedEncodingException e){
        e.printStackTrace();
    }
    post.setRequestEntity(entity);

    try{
        client.executeMethod(post);
    } catch(IOException e){
        e.printStackTrace();
    } catch(HTTPException e){
        e.printStackTrace();
    }
}