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



我可以从已经实现的工作灯示例中获得结果,如rss、googlemapapi等……但我不知道如何评估我自己的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);
 }

您已经声明了以下内容:

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

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

关于参数,请参阅以下问题:IBM Worklight 6.1-如何在适配器中发送post值?

应该是这样的:

...
...
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);
}

相关内容

最新更新