Http请求失败:java.net.UnknownHostException:http:\ / \ / staging.xxxxxxx.com"

时间:2015-04-08 07:06:30

标签: ibm-mobilefirst worklight-adapters

我可以从已经实现的工作单示例(如rss,google map api等)中获得结果......但我不了解如何评估自己的API。我收到以下错误:

{
   "errors": [
  "Runtime: Http request failed: java.net.UnknownHostException: http:\/\/staging.mycompany.com"
 ],
 "info": [
 ],
 "isSuccessful": false,
 "warnings": [
 ]
  }

myRestAdapter.xml

  <?xml version="1.0" encoding="UTF-8"?>

 <wl:adapter name="myRESTAdapter"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:wl="http://www.ibm.com/mfp/integration"
xmlns:http="http://www.ibm.com/mfp/integration/http">

<displayName>myRESTAdapter</displayName>
<description>myRESTAdapter</description>
<connectivity>
    <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
        <protocol>http</protocol>
        <domain>http://staging.mycompany.com</domain>
        <port>80</port> 
        <connectionTimeoutInMilliseconds>30000</connectionTimeoutInMilliseconds>
        <socketTimeoutInMilliseconds>30000</socketTimeoutInMilliseconds>
        <maxConcurrentConnectionsPerNode>50</maxConcurrentConnectionsPerNode>
        <!-- Following properties used by adapter's key manager for choosing specific certificate from key store  
        <sslCertificateAlias></sslCertificateAlias> 
        <sslCertificatePassword></sslCertificatePassword>
        -->     
    </connectionPolicy>
</connectivity>

<procedure name="getGmapLatLng"/>

   </wl:adapter>

myRESTAdapter-impl.js

 function getGmapLatLng(UserName) {

var input = {
    method : 'post',
    returnedContentType : 'application/json',
    path : '/RESTapi/Rest_LoginValidate.php',  // the method which i want to access, actual url is this "http://mycompany.com/RESTapi/LoginValidate.php"
    parameters : {
        'UserName' : UserName,

    }
};

return WL.Server.invokeHttp(input);
 }

1 个答案:

答案 0 :(得分:2)

您已宣布以下内容:

<protocol>http</protocol>
<domain>http://staging.mycompany.com</domain>

http://节点中删除额外的domain

至于参数,请参阅此问题:IBM Worklight 6.1 - How to send post values in adapter?

应该是这样的:

...
...
function getGmapLatLng(UserName, UserPwd) {
    var input = {
        method : 'post',
        returnedContentType : 'application/json',
        path : '/RESTapi/Rest_LoginValidate.php', 
        parameters : {
            UserName : 'UserName', // note the change in place of the quotation marks.
            UserPwd  : 'UserPwd'
        }
    };

    return WL.Server.invokeHttp(input);
}