Silverlight Web服务 "The remote server returned an error: NotFound"

标签 silverlight web-services

我有一个Silverlight应用程序,该应用程序检索一系列可序列化的类。在这些类中,还有其他可序列化的类,其中一些也在列表中。问题是一切正常,直到我填充了导致Silverlight应用程序抛出异常的可序列化类列表之一,“远程服务器返回了一个错误:NotFound”

这是填充类的代码(不要被只是用信息填充类的大量代码所吓倒):

  private SCharacter getSCharacter(Character userCharacter)
        {
            var iqcb = userCharacter.CharacterBodies;
            var iqcs = userCharacter.CharacterStats;
            var iqgs = userCharacter.CharacterSettings;
            var iqcp = userCharacter.CharacterPoints;
            var iqcproj = userCharacter.CharacterProjectiles;

            var currChar = 
                new SCharacter 
                {
                    characterID = userCharacter.characterID,
                    characterName = userCharacter.characterName,
                    characterClassID = userCharacter.characterClassID,
                    userUsername = userCharacter.userUsername
                };
            foreach (var cb in iqcb)
            {
                var scb = new SCharacterBody();
                scb.body.bodyId = cb.bodyId;
                scb.body.bodyName = cb.Body.bodyName;
                scb.bodyPart.bodyPartId = cb.BodyPart.bodyPartId;
                scb.bodyPart.bodyPartName = cb.BodyPart.bodyPartName;
                currChar.characterBodyList.Add(scb);
            }
            foreach (var cs in iqcs)
            {
                var scs = 
                    new SCharacterStat 
                    { 
                          characterID = cs.characterID,
                          statId = cs.statId,
                          characterStatId = cs.characterStatId,
                          statName = cs.Stat.statName,
                          statValue = cs.statValue                           
                    };
                currChar.characterStatList.Add(scs);
            }
            foreach (var igs in iqgs)
            {
                var scs = new SCharacterSetting
                    {
                        characterID = igs.characterID,
                        modifierId = igs.GameSetting.modifierId,
                        modifierType = igs.GameSetting.Modifier.modifierType,
                        characterSettingId = igs.characterSettingId,
                        settingDescription = igs.GameSetting.settingDescription,
                        settingName = igs.GameSetting.settingName,
                        settingValue = igs.GameSetting.settingValue
                    };
                var gss = igs.GameSetting.Stat;
                scs.stat.statId = gss.statId;
                scs.stat.statName = gss.statName;
                currChar.characterSettingList.Add(scs);
            }
            foreach (var cp in iqcp)
            {
                var scp = new SCharacterPoint
                {
                    characterID = cp.characterID,
                    characterPointsId = cp.characterPointsId,
                    pointsId = cp.pointsId,
                    pointsName = cp.Point.pointsName,
                    pointsValue = cp.pointsValue                    
                };
                currChar.characterPointList.Add(scp);
            }

            foreach (var cp in iqcproj)
            {
                var scp = 
                    new SCharacterProjectile 
                    { 
                         characterId = cp.characterId,
                         characterProjectileId = cp.characterProjectileId,
                         particleId = cp.Projectile.particleId,
                         projectileHeight = cp.Projectile.projectileHeight,
                         projectileWidth= cp.Projectile.projectileWidth,
                         damageId =cp.Projectile.damageId,
                         damageDuration = cp.Projectile.Damage.damageDuration,
                         damageValue = cp.Projectile.Damage.damageValue,
                         projectileName = cp.Projectile.projectileName
                    };
                scp.force.forceName = cp.Projectile.forceName;
                scp.force.impulseX = (float)cp.Projectile.Force.impulseX;
                scp.force.impulseY = (float)cp.Projectile.Force.impulseY;
                scp.force.torque = (float)cp.Projectile.Force.torque;

                scp.projectileParticle.particleId = cp.Projectile.particleId;
                scp.projectileParticle.particleName = cp.Projectile.Particle.particleName;

                foreach (var psv in cp.Projectile.Particle.ParticleSettingValues)
                {
                    var spsv = new SParticleSettingValue();
                    spsv.particleId = psv.particleId;
                    spsv.particleSettingID = psv.particleSettingID;
                    spsv.particleSettingName = psv.ParticleSetting.particleSettingName;
                    spsv.particleSettingValue = psv.particleSettingValue1;
                    spsv.particleSettingValuesID = psv.particleSettingValueID;
                    scp.projectileParticle.particleSettingList.Add(spsv);
                }

                foreach (var pc in cp.Projectile.Particle.ParticleColours)
                {
                    var spc = new SParticleColour();
                    spc.colourHex = pc.colourHex;
                    spc.particleColourId = pc.particleColourId;
                    spc.particleId = pc.particleId;
                    scp.projectileParticle.particleColourList.Add(spc);
                }
                currChar.projectileList.Add(scp);
            }
            return currChar; 
        }

在最后三行代码中有currChar.projectileList.Add(scp);,如果我删除那行代码,一切都会正常。我认为可能引起问题的是ciruclar引用,但我检查了类,但似乎找不到任何类。如果需要,我将粘贴与projectileList有关的类的代码

更新:尝试调试Web服务本身,并且显然XML序列化存在问题,您可以找到问题here

最佳答案

下次,您应该启用WCF跟踪:

将其放在您的web.config文件中:

<system.diagnostics>    
    <sources>
      <source name="System.ServiceModel"
              switchValue="Information, ActivityTracing"
              propagateActivity="true">
        <listeners>
          <add name="traceListener"
              type="System.Diagnostics.XmlWriterTraceListener"
              initializeData= "c:\temp\WEBTraces.log" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>

在此处阅读更多内容:http://msdn.microsoft.com/en-us/library/ms733025.aspx

关于Silverlight Web服务 "The remote server returned an error: NotFound",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/814627/

相关文章:

c# - WebMethod 未被调用。 ASP.NET C#

java - OpenShift 状态 404 - Tomcat 本地工作正常

silverlight - 如何使用 Microsoft Silverlight 连接到我的 SQL Azure 数据库?

c# - Silverlight WCF 抛出远程服务器返回错误 : NotFound

web-services - ServiceStack 客户端和二义性路由

php - 发送 SOAP 1.2

ios - 基于回合的游戏服务器的 websockets 和长轮询之间的区别

silverlight - MVVM专家需要您对MVVM和数据形式的意见

silverlight - 如何在 Telerik silverlight RadGridView 中创建模板列?

silverlight - PagedCollectionView自定义排序