0
我創建了一個JaxWs服務。用戶正試圖用PHP客戶端調用它,唯一的參數是一個字符串。當我使用Eclipse Web服務瀏覽器(測試人員)時,它很好。當用戶嘗試使用PHP時,我在方法中收到一個空的parm。我沒有做任何定製wsdl或代碼。預先感謝任何指針...Jax Ws與PHP客戶端總是發送空parm
方法
@WebService(endpointInterface = "my.endpoint.class")
public class ExternalReportsImpl implements ExternalReports {
private org.w3c.dom.Document doc;
@Resource
private WebServiceContext context;
private enum Types {
tfbData, tfbRate, tfbSupport, tfbMakes, tfbVin, tfbSave, tfbRetrieve;
}
@Override
public String getReports(String xmlSource){
XmlHelper xh;
SupportTables support = new SupportTables();
Connection con = null;
Policy policy = null;
String schema = "";
String ret = "";
ServletContext servletContext = (ServletContext) context.getMessageContext().get(MessageContext.SERVLET_CONTEXT);
try {
xh = new XmlHelper();
doc = xh.loadDoc(xmlSource);
}
WSDL摘錄
<message name="getReports"><part name="parameters" element="tns:getReports"/></message><message name="getReportsResponse"><part name="parameters" element="tns:getReportsResponse"/></message><portType name="ExternalReports"><operation name="getReports"><input wsam:Action="http://my.class/ExternalReports/getReportsRequest" message="tns:getReports"/><output wsam:Action="http://my.class/ExternalReports/getReportsResponse" message="tns:getReportsResponse"/></operation></portType>
PHP客戶端
error_reporting(E_ALL);
$url = 'http://my.endpoint/ExternalReportsWebService?wsdl';
$client = new SoapClient($url);
class getReports {
function __construct($arg0) {
$this->getReports = $arg0;
}
}
class getReportsResponse {
function __construct($arg0='') {
$this->getReportsResponse = $arg0;
}
}
//$GR = new getReports(file_get_contents("test/test.xml"));
$GR = new getReports("test"));
$GRR = new getReportsResponse();
$report = new SoapVar($GR , SOAP_ENC_OBJECT, 'getReports', $url);
$response = new SoapVar($GRR , SOAP_ENC_OBJECT, 'getReportsResponse', $url);
echo nl2br(htmlspecialchars(print_r($client->getReports($report, $response), true)));
將此代碼添加到PHP客戶端
echo "<br> LAST REQUEST <br>" ;
echo $client->__getLastRequest();
echo " <br> Functions <br>" ;
echo $client->__getFunctions();
echo " <br> Types <br>" ;
echo $client->__getTypes();
echo "<br> Request headers <br>" ;
echo $client->__getLastRequestHeaders();
CLIENT跟蹤結果
LAST REQUEST
TEST
Functions
Array
Types
Array
Request headers
POST /myApp/ExternalReportsWebService HTTP/1.1 Host: localhost:8080 Connection: Keep-Alive User-Agent: PHP-SOAP/5.3.14 Content-Type: text/xml; charset=utf-8 SOAPAction: "" Content-Length: 531
哼,很難說......您是否嘗試跟蹤從PHP客戶端發送的SOAP消息? – home
我在Java端進行了調試。我前兩天開始編碼PHP,試圖弄清楚這一點。我嘗試了所有可以爲PHP客戶端找到的例子,但都沒有成功。我將研究PHP中的Soap跟蹤 –
@home當我設置跟蹤時,我看到了應該使用echo $ client - > __ getLastRequest()發送的字符串parm。 –