.NET

2012-08-03 25 views
6

में एसओएपी अनुरोध हम विजुअल स्टूडियो सी # का उपयोग कर बुकिंग एपीआई के साथ बातचीत करने के लिए एसओएपी अनुरोधों का उपयोग करने की कोशिश कर रहे हैं।.NET

हमने बिना किसी समस्या के किसी अन्य एपीआई की वेब सेवा में हस्तक्षेप किया है लेकिन यह समस्याग्रस्त साबित हो रहा है।

हमने इसे एक सेवा संदर्भ के रूप में जोड़ा है और विजुअल स्टूडियो ने इसके लिए सभी कक्षाएं और web.config प्रविष्टियां उत्पन्न की हैं ताकि सभी अच्छी तरह से दिखाई दे सकें।

लेकिन जब हम कोशिश करते हैं और ग्राहक सोप सेवा हम निम्न त्रुटि प्राप्त करने के लिए एक सरल अनुरोध करना:

Namespace='com.hrs.soap.hrs' is not supported with rpc\literal SOAP. The wrapper element has to be unqualified.

कोड है:

PingRequest pingrequest = new PingRequest();  
SoapServiceClient service = new SoapServiceClient(); 
service.ping(pingrequest); 

यह वही है वेब में जोड़ दिया गया है। कॉन्फ़िगरेशन फ़ाइल:

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="HRSSoapServiceBinding" closeTimeout="00:01:00" 
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
      maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
      useDefaultWebProxy="true"> 
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
       maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      <security mode="None"> 
      <transport clientCredentialType="None" proxyCredentialType="None" 
       realm="" /> 
      <message clientCredentialType="UserName" algorithmSuite="Default" /> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="..." 
      binding="basicHttpBinding" bindingConfiguration="HRSSoapServiceBinding" 
      contract="HRSService.HRSSoapService" name="HRSSoapServicePort" /> 
    </client> 
    </system.serviceModel> 

दस्तावेज़ीकरण के अनुसार अनुरोध को देखना चाहिए llowing:

<complexType name="PingRequest"> 
    <complexContent> 
     <extension base="tns:Request"> 
      <sequence> 
       <element name="echoData" type="xsd:string"/> 
      </sequence> 
     </extension> 
    </complexContent> 
</complexType> 

पूर्ण स्टैक ट्रेस नीचे:

[InvalidOperationException: Namespace='com.hrs.soap.hrs' is not supported with rpc\literal SOAP. The wrapper element has to be unqualified.] 
    System.Xml.Serialization.XmlReflectionImporter.CheckTopLevelAttributes(XmlAttributes a, String accessorName) +842469 
    System.Xml.Serialization.XmlReflectionImporter.ImportAccessorMapping(MemberMapping accessor, FieldModel model, XmlAttributes a, String ns, Type choiceIdentifierType, Boolean rpc, Boolean openModel, RecursionLimiter limiter) +4072651 
    System.Xml.Serialization.XmlReflectionImporter.ImportMemberMapping(XmlReflectionMember xmlReflectionMember, String ns, XmlReflectionMember[] xmlReflectionMembers, Boolean rpc, Boolean openModel, RecursionLimiter limiter) +699 
    System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(XmlReflectionMember[] xmlReflectionMembers, String ns, Boolean hasWrapperElement, Boolean rpc, Boolean openModel, RecursionLimiter limiter) +298 

[InvalidOperationException: There was an error reflecting 'HRSException'.] 
    System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(XmlReflectionMember[] xmlReflectionMembers, String ns, Boolean hasWrapperElement, Boolean rpc, Boolean openModel, RecursionLimiter limiter) +1051 
    System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(String elementName, String ns, XmlReflectionMember[] members, Boolean hasWrapperElement, Boolean rpc, Boolean openModel, XmlMappingAccess access) +137 
    System.ServiceModel.Description.XmlSerializerImporter.ImportMembersMapping(XmlName elementName, String ns, XmlReflectionMember[] members, Boolean hasWrapperElement, Boolean rpc, Boolean isEncoded, String mappingKey) +237 
    System.ServiceModel.Description.OperationReflector.ImportMembersMapping(String elementName, String ns, XmlReflectionMember[] members, Boolean hasWrapperElement, Boolean rpc, String mappingKey) +134 
    System.ServiceModel.Description.OperationReflector.ImportFaultElement(FaultDescription fault, XmlQualifiedName& elementName) +458 
    System.ServiceModel.Description.OperationReflector.GenerateXmlSerializerFaultContractInfos() +153 
    System.ServiceModel.Description.OperationReflector.EnsureMessageInfos() +929 
    System.ServiceModel.Description.Reflector.EnsureMessageInfos() +98 
    System.ServiceModel.Description.XmlSerializerOperationBehavior.CreateFormatter() +32 
    System.ServiceModel.Description.XmlSerializerOperationBehavior.System.ServiceModel.Description.IOperationBehavior.ApplyClientBehavior(OperationDescription description, ClientOperation proxy) +42 
    System.ServiceModel.Description.DispatcherBuilder.BindOperations(ContractDescription contract, ClientRuntime proxy, DispatchRuntime dispatch) +94 
    System.ServiceModel.Description.DispatcherBuilder.ApplyClientBehavior(ServiceEndpoint serviceEndpoint, ClientRuntime clientRuntime) +247 
    System.ServiceModel.Description.DispatcherBuilder.BuildProxyBehavior(ServiceEndpoint serviceEndpoint, BindingParameterCollection& parameters) +342 
    System.ServiceModel.Channels.ServiceChannelFactory.BuildChannelFactory(ServiceEndpoint serviceEndpoint, Boolean useActiveAutoClose) +85 
    System.ServiceModel.ChannelFactory.CreateFactory() +43 
    System.ServiceModel.ChannelFactory.OnOpening() +23 
    System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +274 
    System.ServiceModel.ChannelFactory.EnsureOpened() +107 
    System.ServiceModel.ChannelFactory`1.CreateChannel(EndpointAddress address, Uri via) +134 
    System.ServiceModel.ChannelFactory`1.CreateChannel() +29 
    System.ServiceModel.ClientBase`1.CreateChannel() +91 
    System.ServiceModel.ClientBase`1.CreateChannelInternal() +26 
    System.ServiceModel.ClientBase`1.get_Channel() +261 
    BLL.HRSService.HRSSoapServiceClient.ping(HRSPingRequest pingRequest) in C:\Code\-------\BLL\Service References\HRSService\Reference.cs:15850 
    -------.Test.Ping() in C:\Code\-------\Test.aspx.cs:48 
    -------.Test.Page_Load(Object sender, EventArgs e) in C:\Code\-------\Test.aspx.cs:24 
    System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 
    System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35 
    System.Web.UI.Control.OnLoad(EventArgs e) +91 
    System.Web.UI.Control.LoadRecursive() +74 
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207 

हम फ़िडलर स्थापित किया है और वहाँ कोई एक्सएमएल अनुरोध है कि हम देख सकते हैं, शायद क्योंकि यह एक अपवाद फेंकता है कुछ भी भेजे जाने से पहले के माध्यम से जा रहा है।

इस काम को करने के लिए हमें अपने सेटअप में वास्तव में क्या बदलने की ज़रूरत है?

अद्यतन

डबल्यूएसडीएल: उपलब्ध [यहां] [1]

अद्यतन

davidfmatheson उत्तम सलाह मैं डबल्यूएसडीएल स्थानीय रूप से नकल की और संशोधन किए गए हैं के बाद सुझाव दिया के रूप में । मैं अभी भी एक अलग जगह में हालांकि संभवतः एक ही त्रुटि हो रही है:

[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] 
     BLL.HRSService.pingResponse BLL.HRSService.HRSSoapService.ping(BLL.HRSService.pingRequest request) { 
      return base.Channel.ping(request); 
     } 

     public BLL.HRSService.HRSPingResponse ping(BLL.HRSService.HRSPingRequestWrapper ping1) { 
      BLL.HRSService.pingRequest inValue = new BLL.HRSService.pingRequest(); 
      inValue.ping = ping1; 
      BLL.HRSService.pingResponse retVal = ((BLL.HRSService.HRSSoapService)(this)).ping(inValue); 
      return retVal.pingResponse1; 
     } 

लाइन है कि विफल रहता है वापसी base.Channel.ping (अनुरोध) है; त्रुटि नामस्थान = 'com.hrs.soap.hrs' आरपीसी \ शाब्दिक SOAP के साथ समर्थित नहीं है। रैपर तत्व को अयोग्य होना चाहिए।

मैं भी स्पष्ट रूप से SOAPBinding सेट करने की कोशिश की:

Exception Details: System.InvalidOperationException: Namespace='com.hrs.soap.hrs' is not supported with rpc\literal SOAP. The wrapper element has to be unqualified. 

Source Error: 

Line 15917:  [System.Web.Services.Protocols.SoapDocumentMethod(Use = System.Web.Services.Description.SoapBindingUse.Literal)] 
Line 15918:  BLL.HRSService.pingResponse BLL.HRSService.HRSSoapService.ping(BLL.HRSService.pingRequest request) { 
Line 15919:   return base.Channel.ping(request); 
Line 15920:  } 
Line 15921: 

ठीक अब मैं अपने स्थानीय WSDL में दस्तावेज़ के लिए सोप बाध्यकारी शैली में संशोधन किया है और कक्षाएं निर्मित और मुझे कोई दूसरी त्रुटि है:

Unable to generate a temporary class (result=1). 
error CS0030: Cannot convert type 'BLL.HRSService.HRSHotelTaxDetail[]' to 'BLL.HRSService.HRSHotelTaxDetail' 
error CS0030: Cannot convert type 'BLL.HRSService.HRSHotelAmenityCriterion[]' to 'BLL.HRSService.HRSHotelAmenityCriterion' 
error CS0029: Cannot implicitly convert type 'BLL.HRSService.HRSHotelTaxDetail' to 'BLL.HRSService.HRSHotelTaxDetail[]' 
error CS0029: Cannot implicitly convert type 'BLL.HRSService.HRSHotelAmenityCriterion' to 'BLL.HRSService.HRSHotelAmenityCriterion[]' 

StackTrace:

[InvalidOperationException: Unable to generate a temporary class (result=1). 
error CS0030: Cannot convert type 'BLL.HRSService.HRSHotelTaxDetail[]' to 'BLL.HRSService.HRSHotelTaxDetail' 
error CS0030: Cannot convert type 'BLL.HRSService.HRSHotelAmenityCriterion[]' to 'BLL.HRSService.HRSHotelAmenityCriterion' 
error CS0029: Cannot implicitly convert type 'BLL.HRSService.HRSHotelTaxDetail' to 'BLL.HRSService.HRSHotelTaxDetail[]' 
error CS0029: Cannot implicitly convert type 'BLL.HRSService.HRSHotelAmenityCriterion' to 'BLL.HRSService.HRSHotelAmenityCriterion[]' 
] 
    System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence) +1024 
    System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly assembly, Hashtable assemblies) +1997 
    System.Xml.Serialization.XmlSerializer.GetSerializersFromCache(XmlMapping[] mappings, Type type) +772 
    System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Type type) +4066268 
    System.ServiceModel.Description.SerializerGenerationContext.GenerateSerializers() +185 
    System.ServiceModel.Description.SerializerGenerationContext.GetSerializer(Int32 handle) +102 
    System.ServiceModel.Description.MessageInfo.get_BodySerializer() +17 
    System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.SerializeBody(XmlDictionaryWriter writer, MessageVersion version, String action, MessageDescription messageDescription, Object returnValue, Object[] parameters, Boolean isRequest) +112 

[CommunicationException: There was an error in serializing body of message pingRequest: 'Unable to generate a temporary class (result=1). 
error CS0030: Cannot convert type 'BLL.HRSService.HRSHotelTaxDetail[]' to 'BLL.HRSService.HRSHotelTaxDetail' 
error CS0030: Cannot convert type 'BLL.HRSService.HRSHotelAmenityCriterion[]' to 'BLL.HRSService.HRSHotelAmenityCriterion' 
error CS0029: Cannot implicitly convert type 'BLL.HRSService.HRSHotelTaxDetail' to 'BLL.HRSService.HRSHotelTaxDetail[]' 
error CS0029: Cannot implicitly convert type 'BLL.HRSService.HRSHotelAmenityCriterion' to 'BLL.HRSService.HRSHotelAmenityCriterion[]' 
'. Please see InnerException for more details.] 
    System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +9440287 
    System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +345 
    BLL.HRSService.HRSSoapService.ping(pingRequest request) +0 
    BLL.HRSService.HRSSoapServiceClient.BLL.HRSService.HRSSoapService.ping(pingRequest request) in C:\Code\...\BLL\Service References\HRSService\Reference.cs:17311 
    BLL.HRSService.HRSSoapServiceClient.ping(HRSPingRequestWrapper ping1) in C:\Code\...\BLL\Service References\HRSService\Reference.cs:17317 
    BLL.HRS_Integration.Ping() in C:\Code\...\BLL\General\HRSIntegration.cs:55 
    VenueOptions.Test.Page_Load(Object sender, EventArgs e) in C:\Code\...\Test.aspx.cs:24 
    System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 
    System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35 
    System.Web.UI.Control.OnLoad(EventArgs e) +91 
    System.Web.UI.Control.LoadRecursive() +74 
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207 

अंत में अनुरोध किया गया!

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><ping xmlns="com.hrs.soap.hrs"><pingRequest xmlns=""><credentials><clientType>...</clientType><clientKey>...</clientKey><clientPassword>...</clientPassword><customerKey xsi:nil="true"/></credentials><myHRSCredentials xsi:nil="true"/><echoData>Hello HRS</echoData></pingRequest></ping></s:Body></s:Envelope> 
+0

स्टैक ट्रेस की जांच करें और देखें कि आपका कोड कहां क्रैक हो रहा है। क्या यह अनुरोध में भूलभुलैया या प्रतिक्रिया डी-क्रमबद्धता धुंध का निर्माण है? – linkerro

+0

मुझे ईमानदार होने की ज़रूरत नहीं है, स्टैक ट्रेस – cusimar9

+0

जिज्ञासा से बाहर, wsdl.exe एक काम कर रहे प्रॉक्सी उत्पन्न करने में सक्षम है? –

उत्तर

6

आप नेट से एक RPC-शाब्दिक सेवा का उपभोग करने के प्रयास कर रहे हैं, तो आप दस्तावेज़-शाब्दिक को सेवा कन्वर्ट करने के लिए हो सकता है:

फ़िडलर PING के लिए निम्नलिखित पता चलता है। MSDN Blog देखें।

संपादित करें: अधिक पूरा जवाब

लक्ष्य डॉक-शाब्दिक उपयोग करने के लिए, लेकिन अभी भी एक ही संदेश भेजने में सक्षम होना है। चलिए ping ऑपरेशन पर ध्यान केंद्रित करते हैं। अभी अपने डबल्यूएसडीएल प्रकार के रूप में परिभाषित किया गया है:

<complexType name="HRSPingRequest"> 
    <complexContent> 
     <extension base="tns:HRSRequest"> 
      <sequence> 
       <element name="echoData" type="xsd:string"/> 
      </sequence> 
     </extension> 
    </complexContent> 
</complexType> 

और अपने संदेश के रूप में परिभाषित:

<message name="HRSSoapService_pingRequest"> 
    <part name="pingRequest" type="tns:HRSPingRequest"/> 
</message> 

और अपने रूप में परिभाषित किया बंधन:

<binding name="HRSSoapServiceBinding" type="tns:HRSSoapService"> 
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> 
    <operation name="ping"> 
     <soap:operation soapAction=""/> 
     <input> 
      <soap:body namespace="com.hrs.soap.hrs" use="literal"/> 
     </input> 
     <output> 
      <soap:body namespace="com.hrs.soap.hrs" use="literal"/> 
     </output> 
     <fault name="HRSException"> 
      <soap:fault name="HRSException" use="literal"/> 
     </fault> 
    </operation> 
</binding> 
तो स्थानीय स्तर पर

हम "RPC बदलने "टू दस्तावेज़" और फिर डब्लूएसडीएल को वास्तविक दस्तावेज़/शाब्दिक में ठीक करें:

<element name="ping" type="tns:HRSPingRequestWrapper" /> 
<complexType name="HRSPingRequestWrapper"> 
    <sequence> 
     <element name="pingRequest" type="tns:HRSPingRequest" /> 
    </sequence> 
</complexType> 
<complexType name="HRSPingRequest"> 
    <complexContent> 
     <extension base="tns:HRSRequest"> 
      <sequence> 
       <element name="echoData" type="xsd:string"/> 
      </sequence> 
     </extension> 
    </complexContent> 
</complexType> 

... 

<message name="HRSSoapService_pingRequest"> 
    <part name="pingRequest" element="tns:ping"/> 
</message> 

अब इस डब्लूएसडीएल से उत्पन्न हो जाएं और देखें कि क्या यह एक पिंग अनुरोध भेजता है। यदि आप प्रतिक्रिया संरचना को ठीक नहीं करते हैं, तो यह समझ में नहीं आता कि वापस क्या आता है, लेकिन आपको कम से कम तार पर भेजे गए अनुरोध को देखना चाहिए। आप डब्ल्यूएसडीएल दोनों को लोड करने के लिए सोपूआई का उपयोग कर सकते हैं और देख सकते हैं कि किस तरह के अनुरोध उत्पन्न होते हैं। लक्ष्य आरपीसी/शाब्दिक के बजाय दस्तावेज़/शाब्दिक का उपयोग करके, वही अनुरोध भेजना है।

+0

लिंक के लिए धन्यवाद, हम एक अच्छा नजर डालेंगे। नहीं, हमारे पास वेब सेवा निर्माता का नियंत्रण नहीं है। यह सब होना चाहिए उससे अधिक जटिल लगता है। – cusimar9

+0

हम सेवा को डॉक्टर-शाब्दिक में परिवर्तित नहीं कर सकते क्योंकि हमारे पास सेवा का कोई नियंत्रण नहीं है। हमने सभी ऑटो जेनरेटेड क्लास में [SoapRpcService (Use = SoapBindingUse.Literal)] जोड़ने का प्रयास किया है, लेकिन हमें बस एक ही त्रुटि मिलती है। – cusimar9

+1

मुझे लगता है कि ब्लॉग एंट्री केवल डब्लूएसडीएल और सेवा से स्कीमा लेने, इसे स्थानीय रूप से सहेजने, इसे संशोधित करने के रूप में संशोधित करने, उस संशोधित स्थानीय डब्लूएसडीएल के स्टब्स को उत्पन्न करने के बारे में बात कर रही है, फिर भी क्लाइंट को मूल एंडपॉइंट पते पर इंगित करती है। यह एक पुराना ब्लॉग पोस्ट है, और मैंने कभी भी यह कोशिश नहीं की है, लेकिन मुझे लगता है कि वे यही सुझाव दे रहे हैं। – davidfmatheson