2012-09-03 7 views
9

इस प्रकार मेरे वेब सेवा सोप शरीर में उपसर्ग गुजर बिना अपने ग्राहक के अनुरोध जब ग्राहक वेब सेवा बुला रहा है प्रोसेस करने में सक्षम नहीं है:WebService सोप शरीर एक नामस्थान उपसर्ग नहीं होने के साथ अनुरोध को संभाल नहीं सकता

<soap:Body> 
<GetPatientResultsRequest xmlns="http://urlA"> 
    <PatientIdentification> 
     <PersonCivilRegistrationIdentifier xmlns="http://UrlB"/> 
    </PatientIdentification> 
    <Period> 
    <From>2012-05-26</From> 
    <To>2012-06-26</To> 
    </Period> 
</GetPatientResultsRequest> 
</soap:Body> 

त्रुटि यह है कि जावा ऑब्जेक्ट GetPatientResultsRequest से संबंधित है और अन्य शून्य हैं।

ऐसा लगता है कि शरीर में कोई उपसर्ग नहीं होने पर, deserialization ठीक से नहीं हो रहा है। मेरे वेब सेवा केवल प्रतिक्रिया करने में सक्षम है जब सोप शरीर

की तरह एक उपसर्ग
<soap:Body> 
<m:GetPatientResultsRequest xmlns:m="http://urlA"> 
    <PatientIdentification> 
     <PersonCivilRegistrationIdentifier xmlns="http://UrlB"/> 
    </PatientIdentification> 
    <Period> 
    <From>2012-05-26</From> 
    <To>2012-06-26</To> 
    </Period> 
</m:GetPatientResultsRequest> 
</soap:Body> 

किसी को भी मुझे पता है क्या है कि मेरी वेब सेवा सभी प्रकार के साबुन अनुरोध ले जा सकते हैं (ऐसा करने के लिए करते हैं सकता है यानी के साथ और उपसर्ग के बिना में तन)?

मैं JAX-WS (सोप 1,1)

+0

आप किस ग्राहक का उपयोग करते हैं? jaxws? – Cris

+1

आपके दो उदाहरण अलग हैं। पहले मामले में, नामस्थान 'GetPatientResultsRequest' और' रोगी पहचान ',' अवधि ', 'से' और 'से' तत्वों पर है। दूसरे उदाहरण में, यह केवल 'GetPatientResultsRequest' तत्व पर है। –

+0

मुझे एक ही समस्या का सामना करना पड़ रहा है। कृपया मुझे बताएं कि क्या आप इस मुद्दे को हल करने में सक्षम थे ... –

उत्तर

8

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

आपके पहले संदेश में आपने एक डिफ़ॉल्ट नेमस्पेस (xmlns रैपर में विशेषता के कारण) परिभाषित किया है और आपके सभी तत्व जो इसे अविकसित नहीं करते हैं और जिनके पास कोई उपसर्ग समान नामस्थान में नहीं है क्योंकि वे इसे अपने माता-पिता से प्राप्त करते हैं ।

आपके दूसरे संदेश में आपके पास एक स्पष्ट उपसर्ग घोषणा है और केवल उस नामस्थान में रैपर है, अन्य तत्व नामस्थान में नहीं हैं और माता-पिता से डिफ़ॉल्ट एक का वारिस नहीं करते हैं (xmlns विशेषता गायब होने के कारण)।

जैसा कि मैंने शुरुआत में कहा था, वेब सेवा अनुबंध को परिभाषित करती है। क्लाइंट से गलत संदेशों को स्वीकार करने के लिए सेवा को बदलने के बजाय ग्राहकों को सही संदेश भेजने के लिए संशोधित करना अधिक समझ में आता है।

अपने तत्वों में से नामस्थान आप JAX-WS एनोटेशन अपने वेब सेवा और ग्राहक की पर targetNamespace मूल्यों का उपयोग करने की आवश्यकता को नियंत्रित करने के।

जब आप लक्ष्य नामस्थान बदलते हैं तो कोड और संदेश प्रारूप में अंतर देखने के लिए यहां एक उदाहरण दिया गया है।

<?xml version="1.0" encoding="utf-8"?> 
<wsdl:definitions 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
xmlns:tns="http://tempuri.org" 
xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
targetNamespace="http://tempuri.org" 
name="CalculatorWS"> 
    <wsdl:types> 
    <xs:schema targetNamespace="http://tempuri.org"> 
     <xs:element name="add" type="tns:add" /> 
     <xs:element name="addInput" type="tns:addInput" /> 
     <xs:element name="addResponse" type="tns:addResponse" /> 
     <xs:element name="addOutput" type="tns:addOutput" /> 
     <xs:complexType name="add"> 
     <xs:sequence> 
      <xs:element name="addInput" type="tns:addInput" /> 
     </xs:sequence> 
     </xs:complexType> 
     <xs:complexType name="addInput"> 
     <xs:sequence> 
      <xs:element name="a" type="xs:int" /> 
      <xs:element name="b" type="xs:int" /> 
     </xs:sequence> 
     </xs:complexType> 
     <xs:complexType name="addResponse"> 
     <xs:sequence> 
      <xs:element name="addOutput" type="tns:addOutput" /> 
     </xs:sequence> 
     </xs:complexType> 
     <xs:complexType name="addOutput"> 
     <xs:sequence> 
      <xs:element name="result" type="xs:int" /> 
     </xs:sequence> 
     </xs:complexType> 
    </xs:schema> 
    </wsdl:types> 
    <wsdl:message name="add"> 
    <wsdl:part name="parameters" element="tns:add" /> 
    </wsdl:message> 
    <wsdl:message name="addResponse"> 
    <wsdl:part name="parameters" element="tns:addResponse" /> 
    </wsdl:message> 
    <wsdl:portType name="CalculatorWS"> 
    <wsdl:operation name="add"> 
     <wsdl:input message="tns:add" /> 
     <wsdl:output message="tns:addResponse" /> 
    </wsdl:operation> 
    </wsdl:portType> 
    <wsdl:binding name="CalculatorWSPortBinding" type="tns:CalculatorWS"> 
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> 
    <wsdl:operation name="add"> 
     <soap:operation soapAction="http://tempuri.org/add" /> 
     <wsdl:input> 
     <soap:body use="literal" /> 
     </wsdl:input> 
     <wsdl:output> 
     <soap:body use="literal" /> 
     </wsdl:output> 
    </wsdl:operation> 
    </wsdl:binding> 
    <wsdl:service name="CalculatorWSService"> 
    <wsdl:port name="CalculatorWSPort" binding="tns:CalculatorWSPortBinding"> 
     <soap:address location="http://localhost:8080/WebServices/CalculatorWS" /> 
    </wsdl:port> 
    </wsdl:service> 
</wsdl:definitions> 

इस तरह संदेशों को परिभाषित करता है:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
     xmlns:tem="http://tempuri.org"> 
    <soapenv:Body> 
     <tem:add> 
     <addInput> 
      <a>?</a> 
      <b>?</b> 
     </addInput> 
     </tem:add> 
    </soapenv:Body> 
</soapenv:Envelope> 

और:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
     xmlns:tem="http://tempuri.org"> 
    <soapenv:Body> 
     <tem:addResponse> 
     <addOutput> 
      <result>?</result> 
     </addOutput> 
     </tem:addResponse> 
    </soapenv:Body> 
</soapenv:Envelope> 

रैपर पर नामस्थान उपसर्ग देखें मैं इस के लिए एक बुनियादी डबल्यूएसडीएल इस्तेमाल करेंगे? ऐसा इसलिए है क्योंकि http://tempuri.org नामस्थान में तत्व घोषित किए गए हैं जबकि अन्य नामस्थान में नहीं हैं और नहीं हैं।

आप नामस्थानों से सभी तत्वों को भी हटा सकते हैं।डबल्यूएसडीएल से लक्ष्य नाम स्थान पट्टी और यह इस तरह देखने के लिए मिलती है:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soapenv:Body> 
     <add> 
     <addInput> 
      <a>?</a> 
      <b>?</b> 
     </addInput> 
     </add> 
    </soapenv:Body> 
</soapenv:Envelope> 

और:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soapenv:Body> 
     <addResponse> 
     <addOutput> 
      <result>?</result> 
     </addOutput> 
     </addResponse> 
    </soapenv:Body> 
</soapenv:Envelope> 

में कोई उपसर्ग

<?xml version="1.0" encoding="utf-8"?> 
<wsdl:definitions 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
name="CalculatorWS"> 
    <wsdl:types> 
    <xs:schema> 
     <xs:element name="add" type="add" /> 
     <xs:element name="addInput" type="addInput" /> 
     <xs:element name="addResponse" type="addResponse" /> 
     <xs:element name="addOutput" type="addOutput" /> 
     <xs:complexType name="add"> 
     <xs:sequence> 
      <xs:element name="addInput" type="addInput" /> 
     </xs:sequence> 
     </xs:complexType> 
     <xs:complexType name="addInput"> 
     <xs:sequence> 
      <xs:element name="a" type="xs:int" /> 
      <xs:element name="b" type="xs:int" /> 
     </xs:sequence> 
     </xs:complexType> 
     <xs:complexType name="addResponse"> 
     <xs:sequence> 
      <xs:element name="addOutput" type="addOutput" /> 
     </xs:sequence> 
     </xs:complexType> 
     <xs:complexType name="addOutput"> 
     <xs:sequence> 
      <xs:element name="result" type="xs:int" /> 
     </xs:sequence> 
     </xs:complexType> 
    </xs:schema> 
    </wsdl:types> 
    <wsdl:message name="add"> 
    <wsdl:part name="parameters" element="add" /> 
    </wsdl:message> 
    <wsdl:message name="addResponse"> 
    <wsdl:part name="parameters" element="addResponse" /> 
    </wsdl:message> 
    <wsdl:portType name="CalculatorWS"> 
    <wsdl:operation name="add"> 
     <wsdl:input message="add" /> 
     <wsdl:output message="addResponse" /> 
    </wsdl:operation> 
    </wsdl:portType> 
    <wsdl:binding name="CalculatorWSPortBinding" type="CalculatorWS"> 
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> 
    <wsdl:operation name="add"> 
     <soap:operation soapAction="http://tempuri.org/add" /> 
     <wsdl:input> 
     <soap:body use="literal" /> 
     </wsdl:input> 
     <wsdl:output> 
     <soap:body use="literal" /> 
     </wsdl:output> 
    </wsdl:operation> 
    </wsdl:binding> 
    <wsdl:service name="CalculatorWSService"> 
    <wsdl:port name="CalculatorWSPort" binding="CalculatorWSPortBinding"> 
     <soap:address location="http://localhost:8080/WebServices/CalculatorWS" /> 
    </wsdl:port> 
    </wsdl:service> 
</wsdl:definitions> 

इस नए डबल्यूएसडीएल जैसे संदेश के अनुरूप होगा ये मामला।

अब दोनों WSDLs पर wsimport.exe का उपयोग करें और आप लक्ष्य नामस्थान कि मैंने शुरू में के बारे में बात कर रहा था, अर्थात् इस से एक बदलाव देखेंगे:

@WebService(name = "CalculatorWS", targetNamespace = "http://tempuri.org") 
public interface CalculatorWS { 
    @WebMethod(action = "http://tempuri.org/add") 
    @WebResult(name = "addOutput", targetNamespace = "") 
    @RequestWrapper(localName = "add", targetNamespace = "http://tempuri.org", className = "your.pack.age.Add") 
    @ResponseWrapper(localName = "addResponse", targetNamespace = "http://tempuri.org", className = "your.pack.age.AddResponse") 
    public AddOutput add(
     @WebParam(name = "addInput", targetNamespace = "") 
     AddInput addInput); 
} 
इस के लिए

:

@WebService(name = "CalculatorWS", targetNamespace = "") 
public interface CalculatorWS { 
    @WebMethod(action = "http://tempuri.org/add") 
    @WebResult(name = "addOutput", targetNamespace = "") 
    @RequestWrapper(localName = "add", targetNamespace = "", className = "your.pack.age.Add") 
    @ResponseWrapper(localName = "addResponse", targetNamespace = "", className = "your.pack.age.AddResponse") 
    public AddOutput add(
     @WebParam(name = "addInput", targetNamespace = "") 
     AddInput addInput); 
} 

नियंत्रण targetNamespace और आप यह नियंत्रित करेंगे कि संदेश कैसा दिखता है।

संबंधित मुद्दे