2012-03-07 30 views
0

有人可以幫我用jQuery嗎?如何用jQuery找到soapAction

我想找到與下面的XML操作名登錄該元素的soapAction屬性(我用的方法已經嘗試找到,但我沒有成功):

<wsdl:definitions name="AuthenticationService" targetNamespace="urn:zeitag.ch.tms.authenticationservice:v1" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="urn:zeitag.ch.tms.authenticationservice:v1" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"> 
<wsdl:types> 
<xsd:schema targetNamespace="urn:zeitag.ch.tms.authenticationservice:v1/Imports"> 
<xsd:import schemaLocation="http://localhost:8833/TimeManagementService/Services/AuthenticationService/?xsd=xsd0" namespace="urn:zeitag.ch.tms.authenticationservice:v1"/> 
<xsd:import schemaLocation="http://localhost:8833/TimeManagementService/Services/AuthenticationService/?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/> 
<xsd:import schemaLocation="http://localhost:8833/TimeManagementService/Services/AuthenticationService/?xsd=xsd2" namespace="urn:zeitag.ch.tms.entities.authenticationservice:v1"/> 
<xsd:import schemaLocation="http://localhost:8833/TimeManagementService/Services/AuthenticationService/?xsd=xsd3" namespace="http://schemas.datacontract.org/2004/07/Ch.ZeitAg.Tms.TimeManagementService.Interface.ServiceEntities.AuthenticationService"/> 
<xsd:import schemaLocation="http://localhost:8833/TimeManagementService/Services/AuthenticationService/?xsd=xsd4" namespace="urn:zeitag.ch.tms.entities.common:v1"/> 
</xsd:schema> 
</wsdl:types> 
<wsdl:message name="AuthenticationService_GetServiceVersion_InputMessage"> 
<wsdl:part name="parameters" element="tns:GetServiceVersion"/> 
</wsdl:message> 
<wsdl:message name="AuthenticationService_GetServiceVersion_OutputMessage"> 
<wsdl:part name="parameters" element="tns:GetServiceVersionResponse"/> 
</wsdl:message> 
<wsdl:message name="AuthenticationService_Login_InputMessage"> 
<wsdl:part name="parameters" element="tns:Login"/> 
</wsdl:message> 
<wsdl:message name="AuthenticationService_Login_OutputMessage"> 
<wsdl:part name="parameters" element="tns:LoginResponse"/> 
</wsdl:message> 
<wsdl:message name="AuthenticationService_Logout_InputMessage"> 
<wsdl:part name="parameters" element="tns:Logout"/> 
</wsdl:message> 
<wsdl:message name="AuthenticationService_Logout_OutputMessage"> 
<wsdl:part name="parameters" element="tns:LogoutResponse"/> 
</wsdl:message> 
<wsdl:message name="AuthenticationService_TouchSession_InputMessage"> 
<wsdl:part name="parameters" element="tns:TouchSession"/> 
</wsdl:message> 
<wsdl:message name="AuthenticationService_TouchSession_OutputMessage"> 
<wsdl:part name="parameters" element="tns:TouchSessionResponse"/> 
</wsdl:message> 
<wsdl:portType name="AuthenticationService"> 
<wsdl:operation name="GetServiceVersion"> 
<wsdl:input wsaw:Action="urn:zeitag.ch.tms.authenticationservice:v1/AuthenticationService/GetServiceVersion" message="tns:AuthenticationService_GetServiceVersion_InputMessage"/> 
<wsdl:output wsaw:Action="urn:zeitag.ch.tms.authenticationservice:v1/AuthenticationService/GetServiceVersionResponse" message="tns:AuthenticationService_GetServiceVersion_OutputMessage"/> 
</wsdl:operation> 
<wsdl:operation name="Login"> 
<wsdl:input wsaw:Action="urn:zeitag.ch.tms.authenticationservice:v1/AuthenticationService/Login" message="tns:AuthenticationService_Login_InputMessage"/> 
<wsdl:output wsaw:Action="urn:zeitag.ch.tms.authenticationservice:v1/AuthenticationService/LoginResponse" message="tns:AuthenticationService_Login_OutputMessage"/> 
</wsdl:operation> 
<wsdl:operation name="Logout"> 
<wsdl:input wsaw:Action="urn:zeitag.ch.tms.authenticationservice:v1/AuthenticationService/Logout" message="tns:AuthenticationService_Logout_InputMessage"/> 
<wsdl:output wsaw:Action="urn:zeitag.ch.tms.authenticationservice:v1/AuthenticationService/LogoutResponse" message="tns:AuthenticationService_Logout_OutputMessage"/> 
</wsdl:operation> 
<wsdl:operation name="TouchSession"> 
<wsdl:input wsaw:Action="urn:zeitag.ch.tms.authenticationservice:v1/AuthenticationService/TouchSession" message="tns:AuthenticationService_TouchSession_InputMessage"/> 
<wsdl:output wsaw:Action="urn:zeitag.ch.tms.authenticationservice:v1/AuthenticationService/TouchSessionResponse" message="tns:AuthenticationService_TouchSession_OutputMessage"/> 
</wsdl:operation> 
</wsdl:portType> 
<wsdl:binding name="BasicHttpBinding_AuthenticationService" type="tns:AuthenticationService"> 
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/> 
<wsdl:operation name="GetServiceVersion"> 
<soap:operation soapAction="urn:zeitag.ch.tms.authenticationservice:v1/AuthenticationService/GetServiceVersion" style="document"/> 
<wsdl:input> 
<soap:body use="literal"/> 
</wsdl:input> 
<wsdl:output> 
<soap:body use="literal"/> 
</wsdl:output> 
</wsdl:operation> 
<wsdl:operation name="Login"> 
<soap:operation soapAction="urn:zeitag.ch.tms.authenticationservice:v1/AuthenticationService/Login" style="document"/> 
<wsdl:input> 
<soap:body use="literal"/> 
</wsdl:input> 
<wsdl:output> 
<soap:body use="literal"/> 
</wsdl:output> 
</wsdl:operation> 
<wsdl:operation name="Logout"> 
<soap:operation soapAction="urn:zeitag.ch.tms.authenticationservice:v1/AuthenticationService/Logout" style="document"/> 
<wsdl:input> 
<soap:body use="literal"/> 
</wsdl:input> 
<wsdl:output> 
<soap:body use="literal"/> 
</wsdl:output> 
</wsdl:operation> 
<wsdl:operation name="TouchSession"> 
<soap:operation soapAction="urn:zeitag.ch.tms.authenticationservice:v1/AuthenticationService/TouchSession" style="document"/> 
<wsdl:input> 
<soap:body use="literal"/> 
</wsdl:input> 
<wsdl:output> 
<soap:body use="literal"/> 
</wsdl:output> 
</wsdl:operation> 
</wsdl:binding> 
<wsdl:service name="AuthenticationService"> 
<wsdl:port name="BasicHttpBinding_AuthenticationService" binding="tns:BasicHttpBinding_AuthenticationService"> 
<soap:address location="http://localhost:8833/TimeManagementService/Services/AuthenticationService/"/> 
</wsdl:port> 
</wsdl:service> 
</wsdl:definitions> 

親切的問候 馬爾科

回答

2

您需要使用命名空間發現:

$(xml).find("soap\\:operation[soapAction]") 

請點擊此處查看演示:http://jsfiddle.net/3A23V/

UPDATE1: 有關具體操作檢查:

$(xml).find("soap\\:operation[soapAction*='Login']") 

DEMO:http://jsfiddle.net/3A23V/1/

+0

非常感謝!這幾乎是我所需要的:)是否有可能獲得完全的soapAction登錄? 感謝和親切的問候 – user886091 2012-03-07 17:08:48

+0

是的,這是可能的,我更新了答案,請檢查 – 2012-03-08 00:34:09

+0

嗨西蒙,非常感謝你!此刻我試圖獲取wsdl:definitions元素的targetNamespace屬性..但不知何故,它不起作用。 我試着用下面的語句:$(xml).find(「wsdl | definitions」 ).attr(「targetNamespace」) 我該怎麼做? – user886091 2012-03-09 12:58:40