我将WSDL存储在客户端提供的本地计算机上,因为它的敏感数据将在公开发布,我将在下面发布修改后的版本。
<wsdl:definitions xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://www.Client.in/StoreLocator" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://www.Client.in/StoreLocator">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://www.Client.in/StoreLocator">
<s:element name="GetClientStore">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="fromLongitude" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="fromLatitude" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetClientStoreResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetClientStoreResult" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="AuthsoapHead" type="tns:AuthsoapHead"/>
<s:complexType name="AuthsoapHead">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="FirstKey" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="SecondKey" type="s:string"/>
</s:sequence>
<s:anyAttribute/>
</s:complexType>
</s:schema>
</wsdl:types>
<wsdl:message name="GetClientStoreSoapIn">
<wsdl:part name="parameters" element="tns:GetClientStore"/>
</wsdl:message>
<wsdl:message name="GetClientStoreSoapOut">
<wsdl:part name="parameters" element="tns:GetClientStoreResponse"/>
</wsdl:message>
<wsdl:message name="GetClientStoreAuthsoapHead">
<wsdl:part name="AuthsoapHead" element="tns:AuthsoapHead"/>
</wsdl:message>
<wsdl:portType name="NearestStoreSoap">
<wsdl:operation name="GetClientStore">
<wsdl:input message="tns:GetClientStoreSoapIn"/>
<wsdl:output message="tns:GetClientStoreSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="NearestStoreSoap" type="tns:NearestStoreSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetClientStore">
<soap:operation soapAction="http://www.Client.in/StoreLocator/GetClientStore" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
<soap:header message="tns:GetClientStoreAuthsoapHead" part="AuthsoapHead" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="NearestStoreSoap12" type="tns:NearestStoreSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetClientStore">
<soap12:operation soapAction="http://www.Client.in/StoreLocator/GetClientStore" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
<soap12:header message="tns:GetClientStoreAuthsoapHead" part="AuthsoapHead" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="NearestStore">
<wsdl:port name="NearestStoreSoap" binding="tns:NearestStoreSoap">
<soap:address location="https://www.Client.in/StoreLocator/neareststore.asmx"/>
</wsdl:port>
<wsdl:port name="NearestStoreSoap12" binding="tns:NearestStoreSoap12">
<soap12:address location="https://www.Client.in/StoreLocator/neareststore.asmx"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
我正在使用Worklight后端服务来获取此SOAP的结果。 在商店定位器服务URL下方查找基于纬度(fromLatitude)和经度(fromLongitude)即https://www.Client.in/StoreLocator/neareststore.asmx获取最近的商店,还查看客户端商店定位器服务URL的测试键(在Request标头中传递值),即FirstKey :FTG8F535DFGDFGER8GFDGG4FG8DGS,SecondKey:密码。
--------------------------------- SoapAdapter1-impl.js --------- -----------------------------
function NearestStore_GetClientStore(params, headers){
var soapEnvNS;
soapEnvNS = 'http://www.w3.org/2003/05/soap-envelope';
var request = buildBody(params, 'xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:tns="http://www.Client.in/StoreLocator" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" ', soapEnvNS);
return invokeWebService(request, headers);
}
function invokeWebService(body, headers){
var input = {
method : 'post',
returnedContentType : 'xml',
path : '/StoreLocator/neareststore.asmx',
body: {
content : body.toString(),
contentType : 'text/xml; charset=utf-8'
}
};
//Adding custom HTTP headers if they were provided as parameter to the procedure call
headers && (input['headers'] = headers);
return WL.Server.invokeHttp(input);
}
现在,我正在使用以下详细信息直接从eclipse调用过程:
{
"GetClientStore": {
"fromLatitude": "18.9750",
"fromLongitude": "72.8258"
}
},{"soapAction": "http://www.Client.in/StoreLocator/GetClientStore","FirstKey":"FTG8F535DFGDFGER8GFDGG4FG8DGS","SecondKey":"password"}
我现在收到的错误如下:
{
"Envelope": {
"Body": {
"Fault": {
"Code": {
"Value": "soap:Receiver"
},
"Detail": "",
"Reason": {
"Text": {
"CDATA": "Server was unable to process request. ---> Object reference not set to an instance of an object.",
"lang": "en"
}
}
}
},
"soap": "http:\/\/www.w3.org\/2003\/05\/soap-envelope",
"xsd": "http:\/\/www.w3.org\/2001\/XMLSchema",
"xsi": "http:\/\/www.w3.org\/2001\/XMLSchema-instance"
},
"errors": [
],
"info": [
],
"isSuccessful": true,
"responseHeaders": {
"Cache-Control": "private",
"Connection": "Keep-Alive",
"Content-Length": "508",
"Content-Type": "application\/soap+xml; charset=utf-8",
"Date": "Wed, 09 Jul 2014 11:57:13 GMT",
"X-Frame-Options": "SAMEORIGIN",
"X-MS-InvokeApp": "1; RequireReadOnly"
},
"responseTime": 158,
"statusCode": 500,
"statusReason": "Internal Server Error",
"totalTime": 159,
"warnings": [
]
}
答案 0 :(得分:0)
最后,我得到了自己的问题的答案。我必须开发一个简单的HTTP适配器,如下所示
function getLocation(latVar, longVar) {
var request =
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:stor="http://www.client.in/StoreLocator">
<soap:Header>
<stor:AuthsoapHead>
<stor:FirstKey>FTG8F535DFGDFGER8GFDGG4FG8DGS</stor:FirstKey>
<stor:SecondKey>password</stor:SecondKey>
</stor:AuthsoapHead>
</soap:Header>
<soap:Body>
<stor:GetclientStore>
<stor:fromLongitude>{longVar}</stor:fromLongitude>
<stor:fromLatitude>{latVar}</stor:fromLatitude>
</stor:GetclientStore>
</soap:Body>
</soap:Envelope>;
var input = {
method : 'post',
returnedContentType : 'xml',
path : '/StoreLocator/neareststore.asmx',
body: {
content: request.toString(),
contentType: 'text/xml; charset=utf-8'
},
};
var result = WL.Server.invokeHttp(input);
var filteredData = result.Envelope.Body.GetclientStoreResponse;
return filteredData;
}
Javascript会显示请求的红色错误标记,但忽略并部署并调用它,我可以看到如下数据:
{
"GetclientStoreResult":
"<Response>
<StatusCode>200<\/StatusCode>
<StoresCount>3<\/StoresCount>
<Stores>
<StoreDetails>
<StoreName>client Store<\/StoreName>
<AddressLine1>Fatehabad Road<\/AddressLine1>
<AddressLine2>Khasra No.-76, Mauja Rajpur, Near Amar Hotel, Fatehabad Road, Agra<\/AddressLine2>
<City>Agra<\/City>
<State>Uttar Pradesh<\/State>
<countryCode>IN<\/countryCode>
<Postalcode>282001<\/Postalcode>
<MainPhone>09x 1x 0x71x0<\/MainPhone>
<MobilePhone>09x 1x9 x97x9x<\/MobilePhone>
<MobilePhone2><\/MobilePhone2>
<HomePage>http:\/\/www.client.in<\/HomePage>
<EMail>clientcare.upw@client.com<\/EMail>
<Timings>1:10:30:19:30,2:10:30:19:30,3:10:30:19:30,4:10:30:19:30,5:10:30:19:30,6:10:30:19:30,7:10:30:19:30<\/Timings>
<PaymentType><\/PaymentType>
<Category>Mobile Service Provider Company<\/Category>
<Description>Service & Sales Store for client<\/Description>
<Latitude>27.164696<\/Latitude>
<Longitude>78.038031<\/Longitude>
<Distance>1.21778962564819<\/Distance>
<\/StoreDetails>
<StoreDetails>
<StoreName>client Store<\/StoreName>
<AddressLine1>VS Pratap Pura<\/AddressLine1>
<AddressLine2>client Store G1 & G2 Ground floor Hotel Usha Kiran Complex Pratap Pura MG Road Agra<\/AddressLine2>
<City>Agra<\/City>
<State>Uttar Pradesh<\/State>
<countryCode>IN<\/countryCode>
<Postalcode>282001<\/Postalcode>
<MainPhone>09x 19 x971x0<\/MainPhone>
<MobilePhone>0x7 19 x7190<\/MobilePhone>
<MobilePhone2><\/MobilePhone2>
<HomePage>http:\/\/www.client.in<\/HomePage>
<EMail>clientcare.upw@client.com<\/EMail>
<Timings>1:10:30:19:30,2:10:30:19:30,3:10:30:19:30,4:10:30:19:30,5:10:30:19:30,6:10:30:19:30,7:10:30:19:30<\/Timings>
<PaymentType><\/PaymentType>
<Category>Mobile Service Provider Company<\/Category>
<Description>Service & Sales Store for client<\/Description>
<Latitude>27.15356<\/Latitude>
<Longitude>78.007565<\/Longitude>
<Distance>4.1715187443831<\/Distance>
<\/StoreDetails>
<StoreDetails>
<StoreName>client Store<\/StoreName>
<AddressLine1>Sanjay Place<\/AddressLine1>
<AddressLine2>Shop No. G-1, Block No. 38\/4B, Sanjay Place, Agra<\/AddressLine2>
<City>Agra<\/City>
<State>Uttar Pradesh<\/State>
<countryCode>IN<\/countryCode>
<Postalcode>282002<\/Postalcode>
<MainPhone>0x7 1x 097x90<\/MainPhone>
<MobilePhone>0x7 19 0xx190<\/MobilePhone>
<MobilePhone2><\/MobilePhone2>
<HomePage>http:\/\/www.client.in<\/HomePage>
<EMail>clientcare.upw@client.com<\/EMail>
<Timings>1:10:30:19:30,2:10:30:19:30,3:10:30:19:30,4:10:30:19:30,5:10:30:19:30,6:10:30:19:30,7:10:30:19:30<\/Timings>
<PaymentType><\/PaymentType>
<Category>Mobile Service Provider Company<\/Category>
<Description>Service & Sales Store for client<\/Description>
<Latitude>27.198541<\/Latitude>
<Longitude>78.006023<\/Longitude>
<Distance>4.4289447148507<\/Distance>
<\/StoreDetails>
<\/Stores>
<\/Response>",
"isSuccessful": true,
"xmlns": "http:\/\/www.client.in\/StoreLocator"
}