我有一个肥皂体,我需要根据这个wsdl定义填充正确的元素。
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://DEA.Web.Service.MasterCalendar.API/">
<s:element name="GetEvents">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="userName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="password" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="startDate" type="s:dateTime"/>
<s:element minOccurs="1" maxOccurs="1" name="endDate" type="s:dateTime"/>
<s:element minOccurs="0" maxOccurs="1" name="eventName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="location" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="calendars" type="tns:ArrayOfInt"/>
<s:element minOccurs="0" maxOccurs="1" name="eventTypes" type="tns:ArrayOfInt"/>
<s:element minOccurs="0" maxOccurs="1" name="udqAnswer" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="ArrayOfInt">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="int" type="s:int"/>
</s:sequence>
</s:complexType>
</s:schema>
</wsdl:types>
填充元素的代码是:
SOAPElement username = bodyElement.addChildElement(sf.createName("userName","SOAP-ENV","http://DEA.Web.Service.MasterCalendar.API/"));
username.addTextNode("username");
SOAPElement password = bodyElement.addChildElement(sf.createName("password","SOAP-ENV","http://DEA.Web.Service.MasterCalendar.API/"));
password.addTextNode("password");
SOAPElement startdate = bodyElement.addChildElement(sf.createName("StartDate","SOAP-ENV","http://DEA.Web.Service.MasterCalendar.API/"));
SOAPElement endate = bodyElement.addChildElement(sf.createName("EndDate","SOAP-ENV","http://DEA.Web.Service.MasterCalendar.API/"));
startdate.addTextNode("2013-02-01");
endate.addTextNode("2013-02-10");
SOAPElement eventName = bodyElement.addChildElement(sf.createName("EventName","SOAP-ENV","http://DEA.Web.Service.MasterCalendar.API/"));
eventName.addTextNode("rock");
SOAPElement location = bodyElement.addChildElement(sf.createName("location","SOAP-ENV","http://DEA.Web.Service.MasterCalendar.API/"));
location.addTextNode("The Well");
SOAPElement calendars = bodyElement.addChildElement(sf.createName("calendars","SOAP-ENV","http://DEA.Web.Service.MasterCalendar.API/"));
SOAPElement calendarId = calendars.addChildElement(sf.createName("int","SOAP-ENV","http://DEA.Web.Service.MasterCalendar.API/"));
calendarId.addTextNode("47");
SOAPElement eventTypes = bodyElement.addChildElement(sf.createName("eventTypes","SOAP-ENV","http://DEA.Web.Service.MasterCalendar.API/"));
SOAPElement eventId = eventTypes.addChildElement(sf.createName("int","SOAP-ENV","http://DEA.Web.Service.MasterCalendar.API/"));
eventId.addTextNode("37");
//SOAPElement eventId2 = eventTypes.addChildElement(sf.createName("int","SOAP-ENV","http://DEA.Web.Service.MasterCalendar.API/"));
SOAPElement udqAnswer = bodyElement.addChildElement(sf.createName("udqAnswer","SOAP-ENV","http://DEA.Web.Service.MasterCalendar.API/"));
udqAnswer.addTextNode("");
发送之前的请求如下所示:
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header/><env:Body>
<SOAP-ENV:GetEvents xmlns:SOAP-ENV="http://DEA.Web.Service.MasterCalendar.API/">
<SOAP-ENV:userName>username</SOAP-ENV:userName>
<SOAP-ENV:password>password</SOAP-ENV:password>
<SOAP-ENV:StartDate>2013-02-01</SOAP-ENV:StartDate>
<SOAP-ENV:EndDate>2013-02-10</SOAP-ENV:EndDate>
<SOAP-ENV:EventName>rock</SOAP-ENV:EventName>
<SOAP-ENV:location>The Well</SOAP-ENV:location>
<SOAP-ENV:calendars>
<SOAP-ENV:int>47</SOAP-ENV:int>
</SOAP-ENV:calendars>
<SOAP-ENV:eventTypes>
<SOAP-ENV:int>37</SOAP-ENV:int>
</SOAP-ENV:eventTypes>
<SOAP-ENV:udqAnswer/>
</SOAP-ENV:GetEvents>
</env:Body></env:Envelope>
不幸的是,服务器的响应很模糊,只是说试图对数据库执行命令时发生了错误。我可以查询其他对服务器的调用而不是这个,我认为它与udqAnswer没有正确关闭有关吗?
底线是 我缺乏肥皂的经验,以确定元素的填充与wsdl定义的不同之处。哪里错了?
答案 0 :(得分:1)
尝试使用SoapUI只发送几条xml消息,看看是否可以生成可以获得正确响应的消息。
第二次尝试删除udqAnswer。当我发送空标签时,我遇到了Web服务的问题,因为它被翻译为null并且存在以下问题:|