Domanda

Io ricevendo un riferimento all'oggetto non impostato su un'istanza di errore dell'oggetto nel mio servizio Web WCF che utilizza WebHTTTPBINDING (SOAP Soap 1.1) ho notato che se hai i parametri di input in un determinato ordine, l'errore non viene sollevato.

I.e.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:not="http://schemas.globalfoundries.com/NotificationService">
   <soapenv:Header/>
   <soapenv:Body>
      <not:NotifyWorkflowItemUpdate>
         <not:userIDs>testUserID</not:userIDs>
         <not:taskID>testTaskID</not:taskID>
         <not:taskType>testTaskType</not:taskType>
         <not:status>testStatus</not:status>
         <not:appID>testAppID</not:appID>
         <not:message>testMessage</not:message>
      </not:NotifyWorkflowItemUpdate>
   </soapenv:Body>
</soapenv:Envelope>
.

Tuttavia se modifico l'ordine dei parametri di input nel modello di richiesta ottengo l'errore sopra menzionato.I.e. (Nota Messaggio e Idra Parametri sono commutati)

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:not="http://schemas.globalfoundries.com/NotificationService">
   <soapenv:Header/>
   <soapenv:Body>
      <not:NotifyWorkflowItemUpdate>
     <not:message>testMessage</not:message>
         <not:taskID>testTaskID</not:taskID>
         <not:taskType>testTaskType</not:taskType>
         <not:status>testStatus</not:status>
         <not:appID>testAppID</not:appID>
         <not:userIDs>testUserID</not:userIDs>
      </not:NotifyWorkflowItemUpdate>
   </soapenv:Body>
</soapenv:Envelope>
.

Perché è questo accadendo?I parametri richiedono i parametri mappati ai parametri del metodo .NET tramite l'ordine e non dai nomi?Esiste un attributo che devo specificare sul contratto di servizio per rendere possibile la mappatura dei parametri denominati?

È stato utile?

Soluzione

È necessario utilizzare XMLSeriaLizerFormat classe nell'interfaccia del servizio WCF.

[ServiceContract, XmlSerializerFormat]
public interface IGoodMessageService
{
    ...
}
.

Problema e soluzione è spiegato in questo link: http://neimke.blogspot.com.tr/2012/03/serializzazione-ordining-Cause-problems.html

Altri suggerimenti

Lo schema XML del tuo messaggio SOAP specifica l'ordine.Nell'ordine XML di questioni elementi e WCF sta convalidando XML sullo schema.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top